Exemplo n.º 1
0
        public BlackListService()
        {
            BlackListDB.InitializeLoader();
            var blacklistTemp = BlackListDB.LoadBlackList();

            if (blacklistTemp != null)
            {
                _guildBlackListDict = blacklistTemp;
                Console.WriteLine("LOADED BLACKLIST");
            }
        }
Exemplo n.º 2
0
        public async Task BlackListUser(SocketCommandContext Context, SocketGuildUser user)
        {
            try
            {
                var mod = Context.User as SocketGuildUser;
                //var user = userT as SocketGuildUser;
                if (!ModIsAllowed(mod, user, Context).Result)
                {
                    return;
                }

                List <ulong> userList = new List <ulong>();
                if (_guildBlackListDict.ContainsKey(Context.Guild.Id))
                {
                    _guildBlackListDict.TryGetValue(Context.Guild.Id, out userList);
                }

                if (userList == null)
                {
                    userList = new List <ulong>();
                }

                if (userList.Contains(user.Id))
                {
                    await Context.Channel.SendMessageAsync(":no_entry_sign: User is already Blacklisted.");

                    return;
                }

                userList.Add(user.Id);
                await Context.Channel.SendMessageAsync(
                    $":white_check_mark: User {user.Username}#{user.DiscriminatorValue} was successfully Blacklisted. He cannot use any of Sora's commands anymore in {Context.Guild.Name}");

                _guildBlackListDict.AddOrUpdate(Context.Guild.Id, userList, (key, oldValue) => userList);
                BlackListDB.SaveBlackList(_guildBlackListDict);
            }
            catch (Exception e)
            {
                await SentryService.SendError(e, Context);
            }
        }