Beispiel #1
0
        public async Task ListFilterWordExcludes(CommandContext ctx)
        {
            if (ctx.Member.GetRole().IsModOrHigher())
            {
                StringBuilder sb = new StringBuilder();

                // Cancels:
                if (Excludes.GetWordCount() == 0)
                {
                    await ctx.Channel.SendMessageAsync(
                        ChatObjects.GetNeutralMessage(@"There are no filter excludes..."));

                    return;
                }

                foreach (string word in Excludes.GetWords())
                {
                    sb.AppendLine(word);
                }

                DiscordEmbedBuilder deb = new DiscordEmbedBuilder()
                {
                    Color       = DiscordColor.LightGray,
                    Description = sb.ToString(),
                    Title       = "FILTER LIST EXCLUDES"
                };

                await ctx.Channel.SendMessageAsync(embed : deb.Build());
            }
        }
Beispiel #2
0
        public async Task RemoveFilterWords(CommandContext ctx, params string[] words)
        {
            // Check if the user can use commands.
            if (ctx.Member.GetRole().IsSeniorModOrHigher())
            {
                await ctx.TriggerTypingAsync();

                StringBuilder       sb_fail    = new StringBuilder(); // A list of words we haven't been able to add.
                StringBuilder       sb_success = new StringBuilder(); // A list of words we were able to add.
                DiscordEmbedBuilder deb;

                foreach (string word in words)
                {
                    // Check if this is already in the filter list. If it is not, we were unsuccessful at adding it to the list.
                    bool success = FilterSystem.IsWord(word);

                    if (success)
                    {
                        FilterSystem.RemoveWord(word);
                        sb_success.Append(word + @", ");
                    }
                    else
                    {
                        sb_fail.Append(word + @", ");
                    }
                }

                // DEB!
                deb = new DiscordEmbedBuilder()
                {
                    Description = ChatObjects.GetNeutralMessage(@"I attempted to remove those words you gave me."),
                    Color       = DiscordColor.LightGray
                };

                deb.WithThumbnailUrl(ChatObjects.URL_FILTER_SUB);

                // For each of these lists, we want to remove the last two characters, because every string will have an ", " at the end of it.
                if (sb_success.Length > 0)
                {
                    deb.AddField("Successfully removed:", sb_success.Remove(sb_success.Length - 2, 2).ToString());
                }
                if (sb_fail.Length > 0)
                {
                    deb.AddField("Not removed:", sb_fail.Remove(sb_fail.Length - 2, 2).ToString());
                }

                FilterSystem.Save();

                await ctx.Channel.SendMessageAsync(embed : deb.Build());
            }
        }
Beispiel #3
0
        public async Task ListExcludes(CommandContext ctx)
        {
            if (ctx.Member.GetRole().IsCHOrHigher())
            {
                await ctx.Channel.TriggerTypingAsync();

                // Cancels:

                if (BotSettings.GetExcludedChannelsCount == 0)
                {
                    await ctx.Channel.SendMessageAsync(
                        ChatObjects.GetNeutralMessage(@"There are no excluded channels..."));

                    return;
                }

                // DEB!
                DiscordEmbedBuilder deb = new DiscordEmbedBuilder
                {
                    Title = "Excluded Channels"
                };

                StringBuilder sb = new StringBuilder();

                // Write out every channel being excluded into a cute little list.
                foreach (DiscordChannel chan in await BotSettings.GetExcludedChannels())
                {
                    sb.AppendLine(chan.Mention);
                }

                deb.Description = sb.ToString();
                deb.WithColor(DiscordColor.LightGray);
                deb.WithThumbnailUrl(ChatObjects.URL_SPEECH_BUBBLE);

                await ctx.Channel.SendMessageAsync(embed : deb);
            }
        }