public async Task FilterExclude(CommandContext ctx, string word) { if (ctx.Member.GetRole().IsSeniorModOrHigher()) { await ctx.TriggerTypingAsync(); // Cancels: if (FilterSystem.IsWord(word)) { await ctx.Channel.SendMessageAsync( ChatObjects.GetErrMessage(@"Cannot add that word. It's a filter word...")); return; } if (Excludes.IsExcluded(word)) { await ctx.Channel.SendMessageAsync( ChatObjects.GetErrMessage(@"Cannot add that word. It's already excluded...")); return; } Excludes.AddWord(word); Excludes.Save(); await ctx.Channel.SendMessageAsync( ChatObjects.GetSuccessMessage( String.Format("I excluded the word {0}!", word))); } }
public async Task FilterAddWords(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 in the filter list or exclude list. If it is, we were unsuccessful at adding it to the list. bool success = !FilterSystem.IsWord(word) && !Excludes.IsExcluded(word); if (success) { FilterSystem.AddWord(word); sb_success.Append(word + @", "); } else { sb_fail.Append(word + @", "); } } // DEB! deb = new DiscordEmbedBuilder() { Description = ChatObjects.GetNeutralMessage(@"I attempted to add those words you gave me."), Color = DiscordColor.LightGray }; deb.WithThumbnailUrl(ChatObjects.URL_FILTER_ADD); // 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 added:", sb_success.Remove(sb_success.Length - 2, 2).ToString()); } if (sb_fail.Length > 0) { deb.AddField(@"Not added:", sb_fail.Remove(sb_fail.Length - 2, 2).ToString()); } FilterSystem.Save(); await ctx.Channel.SendMessageAsync(embed : deb.Build()); } }
public async Task FilterInclude(CommandContext ctx, string word) { if (ctx.Member.GetRole().IsSeniorModOrHigher()) { await ctx.TriggerTypingAsync(); if (!Excludes.IsExcluded(word)) { await ctx.Channel.SendMessageAsync( ChatObjects.GetErrMessage(@"Cannot un-exclude that word. It's not already excluded...")); } else { Excludes.RemoveWord(word); Excludes.Save(); await ctx.Channel.SendMessageAsync( ChatObjects.GetSuccessMessage(@"I removed that word from exclusion!")); } } }