예제 #1
0
        public async Task AddAutoRoleAsync(ulong id, ulong roleId)
        {
            var server = await _context.Servers
                         .FindAsync(id);

            if (server == null)
            {
                _context.Add(new Server {
                    Id = id
                });
            }
            _context.Add(new AutoRole {
                RoleId = roleId, ServerId = id
            });
            await _context.SaveChangesAsync();
        }
예제 #2
0
        public async Task AddWord([Remainder] string word)
        {
            var sb = new StringBuilder();

            using (var db = new DiscbotContext())
            {
                var  words     = db.WordList.AsEnumerable().Where(w => w.ServerId == (long)Context.Guild.Id).ToList();
                bool wordFound = false;
                foreach (var singleWord in words)
                {
                    if (singleWord.Word.ToLower().Contains(word.ToLower()))
                    {
                        wordFound = true;
                    }
                }
                if (wordFound)
                {
                    sb.AppendLine($"[{word}] is already in the list!");
                }
                else
                {
                    sb.AppendLine($"Adding [{word}] to the list!");
                    db.Add(new WordList
                    {
                        ServerId   = (long)Context.Guild.Id,
                        ServerName = Context.Guild.Name,
                        Word       = word,
                        SetById    = (long)Context.User.Id
                    });
                    await db.SaveChangesAsync();
                }
            }
            await _channelServices.Reply(Context, sb.ToString());
        }
예제 #3
0
        public async Task ModifyGuildPrefix(ulong id, string prefix)
        {
            var server = await _context.Servers
                         .FindAsync(id);

            if (server == null)
            {
                _context.Add(new Server {
                    Id = id, Prefix = prefix
                });
            }
            else
            {
                server.Prefix = prefix;
            }
            await _context.SaveChangesAsync();
        }