public override async Task <bool> ReactionAddedAsync()
        {
            if (!(base.Context.Channel.Name?.Contains("bot-spam") ?? false))
            {
                return(false);
            }

            var emote = base.Context.Reaction.Emote switch
            {
                // For this to work, the bot has to be in the same server, the emote is from
                // Because of this, banhammer wont work because the bot is not in the same server
                Discord.Emote em => $"<:{em.Name}:{em.Id}>",
                Discord.Emoji emoji => $"{emoji.Name}",
                _ => ""
            };

            await ReplyAsync($"Reaction added! '{emote}'");

            return(true);
        }
Exemple #2
0
        public async Task <List <string> > CleanOldEmotesAsync(SocketGuild guild)
        {
            await guild.SyncGuildAsync();

            var emoteClearCandidates = GrillBotRepository.EmoteStatsRepository.GetEmotesForClear(guild.Id, 14);

            if (emoteClearCandidates.Count == 0)
            {
                return(new List <string>());
            }

            var removed = new List <string>();

            foreach (var candidate in emoteClearCandidates)
            {
                if (candidate.IsUnicode)
                {
                    var formatedFirstOccured = candidate.FirstOccuredAt.ToLocaleDatetime();
                    var formatedLastOccured  = candidate.LastOccuredAt.ToLocaleDatetime();

                    removed.Add($"> Smazán unicode emote **{candidate.RealID}**. Použití: 0, Poprvé použit: {formatedFirstOccured}, Naposledy použit: {formatedLastOccured}");
                    await GrillBotRepository.EmoteStatsRepository.RemoveEmojiNoCommitAsync(guild, candidate.EmoteID);

                    continue;
                }

                var parsedEmote = Emote.Parse(candidate.RealID);
                if (!guild.Emotes.Any(o => o.Id == parsedEmote.Id))
                {
                    removed.Add($"> Smazán starý emote **{parsedEmote.Name}** ({parsedEmote.Id}). Použito {candidate.UseCount.FormatWithSpaces()}x.");
                    await GrillBotRepository.EmoteStatsRepository.RemoveEmojiNoCommitAsync(guild, candidate.RealID);
                }
            }

            await GrillBotRepository.CommitAsync();

            return(removed);
        }