Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
        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);
        }