Esempio n. 1
0
        public async Task RemoveModRoleAsync(SocketGuildUser u, Server s, SocketGuild g, SocketRole r)
        {
            if (g.Owner != u)
            {
                await ReplyAsync("You must be the owner of the server in order to edit moderator roles.");

                return;
            }
            List <ulong> roles = s.Config.ModeratorRoles;

            if (!roles.Exists())
            {
                s.Config.ModeratorRoles = new List <ulong>();
                roles = s.Config.ModeratorRoles;
            }

            if (!g.HasRole(r.Id))
            {
                await ReplyAsync("This server doesn't have this role.");

                return;
            }

            if (!roles.Contains(r.Id))
            {
                await ReplyAsync("This role doesn't exist in the list of mod roles.");

                return;
            }

            s.Config.ModeratorRoles.Remove(r.Id);
            await ReplyAsync($"{r.Name} ({r.Id}) has been taken out of the moderator roles.");
        }
Esempio n. 2
0
        public bool TrySetMusicRole(SocketGuild g, ulong u)
        {
            if (!g.HasRole(u))
            {
                return(false);
            }

            SetMusicRole(u);
            return(true);
        }
Esempio n. 3
0
        public bool TrySetDefaultVoice(SocketGuild g, ulong u)
        {
            if (!g.HasRole(u))
            {
                return(false);
            }

            SetDefaultVoice(u);
            return(true);
        }
Esempio n. 4
0
        public static bool TryGetRole(this SocketGuild g, string s, out SocketRole role)
        {
            role = null;
            if (!g.HasRole(s))
            {
                return(false);
            }
            if (g.MentionsRole(s))
            {
                role = g.Roles.Where(x => x.Mention == s).First();
                return(true);
            }

            role = g.Roles.Where(x => x.Name.ToLower() == s.ToLower()).First();
            return(true);
        }
Esempio n. 5
0
        public async Task GetServerModRolesAsync(Server s, SocketGuild g)
        {
            List <ulong>      roles   = s.Config.ModeratorRoles;
            List <SocketRole> ensured = new List <SocketRole>();

            if (!roles.Exists())
            {
                await ReplyAsync("this server doesn't have any set moderator roles.");

                return;
            }

            if (roles.Count == 0)
            {
                await ReplyAsync("this server doesn't have any set moderator roles.");

                return;
            }

            foreach (ulong role in roles)
            {
                if (!g.HasRole(role))
                {
                    roles.Remove(role);
                }

                SocketRole r = g.GetRole(role);

                if (ensured.Contains(r))
                {
                    continue;
                }

                ensured.Add(r);
            }


            StringBuilder sb = new StringBuilder();

            foreach (SocketRole r in ensured)
            {
                sb.Append($"{r.Name}\n");
            }

            await ReplyAsync(sb.ToString());
        }