Example #1
0
        public async Task RemModifyRoleAsync([Remainder] string roleName = "")
        {
            if (!ServerData.HasPermissionLevel(BotUtils.GetGUser(Context), ServerData.PermissionLevel.ADMIN))
            {
                return;                                                                                                // This is an admin only command
            }
            if (string.IsNullOrWhiteSpace(roleName))
            {
                await ReplyAsync(BotUtils.KamtroText("Please specify a role name!"));
            }

            ulong id;

            if (ulong.TryParse(roleName, out id) && BotUtils.GetRole(id) != null)
            {
                await RemModifyRole(BotUtils.GetRole(id));

                return;
            }

            // if it's not a recognized ID, treat it as a name

            List <SocketRole> roles = new List <SocketRole>();

            foreach (SocketRole r in BotUtils.GetRoles(roleName))
            {
                if (Program.Settings.ModifiableRoles.Contains(r.Id))
                {
                    roles.Add(r);
                }
            }

            if (roles.Count == 0)
            {
                await ReplyAsync(BotUtils.KamtroText("I couldn't find any roles on the list that matched the name you told me!"));

                return;
            }
            else if (roles.Count > 10)
            {
                await ReplyAsync(BotUtils.KamtroText("There were too many roles with that name! Please be more specific, or use the role ID"));

                return;
            }
            else if (roles.Count == 1)
            {
                await RemModifyRole(roles[0]);
            }
            else
            {
                RoleSelectionEmbed rse = new RoleSelectionEmbed(roles, RemModifyRole, BotUtils.GetGUser(Context));
                await rse.Display(Context.Channel);
            }
        }
Example #2
0
        public async Task AddEmoteRoleAsync([Remainder] string args = "")
        {
            if (!ServerData.HasPermissionLevel(BotUtils.GetGUser(Context), ServerData.PermissionLevel.ADMIN))
            {
                return;                                                                                                // This is an admin only command
            }
            if (string.IsNullOrWhiteSpace(args))
            {
                await ReplyAsync(BotUtils.KamtroText("Please specify a role!"));

                return;
            }

            ulong id;

            if (ulong.TryParse(args, out id) && BotUtils.GetRole(id) != null)
            {
                await AddRoleEmote(BotUtils.GetRole(id));

                return;
            }

            // if it's not a recognized ID, treat it as a name

            List <SocketRole> roles = BotUtils.GetRoles(args);

            if (roles.Count == 0)
            {
                await ReplyAsync(BotUtils.KamtroText("I couldn't find any roles that matched the name you told me!"));

                return;
            }
            else if (roles.Count > 10)
            {
                await ReplyAsync(BotUtils.KamtroText("There were too many roles with that name! Please be more specific, or use the role ID"));

                return;
            }
            else if (roles.Count == 1)
            {
                await AddRoleEmote(roles[0]);
            }
            else
            {
                RoleSelectionEmbed rse = new RoleSelectionEmbed(roles, AddRoleEmote, BotUtils.GetGUser(Context));
                await rse.Display(Context.Channel);
            }
        }