Beispiel #1
0
        public async Task Remove(IUser user)
        {
            var guild      = ((IGuildUser)Context.Message.Author).Guild;
            var authorUser = ((IGuildUser)Context.Message.Author);

            if (!authorUser.GuildPermissions.ManageGuild)
            {
                return;
            }

            var server = BotFiles.GetDiscordServer(guild.Id.ToString());

            if (server.BroadcasterWhitelist == null)
            {
                server.BroadcasterWhitelist = new List <string>();
            }

            if (server.BroadcasterWhitelist.Contains(user.Id.ToString()))
            {
                server.BroadcasterWhitelist.Remove(user.Id.ToString());
                BotFiles.SaveDiscordServer(server);
                await Context.Channel.SendMessageAsync(user.Username + " has been removed from the whitelist.");
            }
            else
            {
                await Context.Channel.SendMessageAsync(user.Username + " was not on the whitelist.");
            }
        }
Beispiel #2
0
        public async Task Off()
        {
            var guild = ((IGuildUser)Context.Message.Author).Guild;

            var user = ((IGuildUser)Context.Message.Author);

            if (!user.GuildPermissions.ManageGuild)
            {
                return;
            }

            var server = BotFiles.GetDiscordServer(guild.Id.ToString());

            server.UseWhitelist = false;
            BotFiles.SaveDiscordServer(server);
            await Context.Channel.SendMessageAsync("Use whitelist has been turned off.");
        }
Beispiel #3
0
        public async Task View()
        {
            var guild = ((IGuildUser)Context.Message.Author).Guild;

            var user = ((IGuildUser)Context.Message.Author);

            if (!user.GuildPermissions.ManageGuild)
            {
                return;
            }

            var server = BotFiles.GetDiscordServer(guild.Id.ToString());

            if (server.BroadcasterWhitelist != null)
            {
                List <IUser> users = new List <IUser>();
                foreach (var u in server.BroadcasterWhitelist)
                {
                    users.Add(await guild.GetUserAsync(ulong.Parse(u)));
                }

                string userList = "";
                int    counter  = 1;
                foreach (var u in users)
                {
                    userList += u.Username;

                    if (counter < users.Count)
                    {
                        userList += ", ";
                    }

                    counter++;
                }

                string info = "```Markdown\r\n" +
                              "# Current Server Whitelist\r\n" +
                              userList + "\r\n" +
                              "```\r\n";

                await Context.Channel.SendMessageAsync(info);
            }
        }