public bool HasBlacklistedWord(SocketUserMessage msg, SocketTextChannel channel) { List <BlacklistedWord> blacklistedWords = BlacklistedWord.Get(channel.Guild.Id); foreach (BlacklistedWord blacklistedWord in blacklistedWords) { if (msg.Content.Contains(blacklistedWord.Word, StringComparison.InvariantCultureIgnoreCase)) { return(true); } } return(false); }
public BlacklistedWord AddWordToBlacklist(string word, ulong guildId) { Core.Logger.LogGenericMessage($"[Mongo] SAVED Blacklisted Word TO {guildId}"); var _userDb = GetDatabaseFromGuildId(guildId); var _collection = _userDb.GetCollection <BlacklistedWord>("blacklistedwords"); var w = new BlacklistedWord { Word = word, Id = _collection.CountDocuments(new BsonDocument()) == 0 ? 1 : (int)_collection.CountDocuments(new BsonDocument()) + 1, Active = true }; _collection.InsertOne(w); return(w); }