Exemple #1
0
        public async Task NewRole([Remainder] string name = "")
        {
            var role = await this.SelectRole(name);

            if (role == null)
            {
                return;
            }

            int userHigh = ((SocketGuildUser)Context.User).Roles.Max(x => x.Position);

            if (userHigh <= role.Position)
            {
                await Context.Channel.SendMessageAsync($":x: You do not have permission to modify `{role.Name}`! Make sure you have a role higher in the list.");

                return;
            }

            if (!PublicRoleDb.IsPublic(role.Id))
            {
                await PublicRoleDb.Add(role.Id, Context.Guild.Id);

                await Context.Channel.SendMessageAsync($"`{role.Name}` set as a public role.");

                return;
            }
            else
            {
                await PublicRoleDb.Delete(role.Id);

                await Context.Channel.SendMessageAsync($"`{role.Name}` removed from public roles.");

                return;
            }
        }
Exemple #2
0
        public async Task PublicRoleList([Remainder] string str = "")
        {
            var roles = new List <SocketRole>();

            foreach (var x in PublicRoleDb.GetAll(Context.Guild.Id))
            {
                roles.Add(Context.Guild.GetRole(x.RoleId));
            }

            var eb = RoleUtil.PublicRoleListEmbed(roles);
            await Context.Channel.SendMessageAsync("", false, eb.Build());
        }
Exemple #3
0
        public async Task Role([Remainder] string name = "")
        {
            var role = await this.SelectRole(name, PublicRoleDb.GetAll(Context.Guild.Id).Select(x => x.RoleId), false);

            if (role == null)
            {
                await ReplyAsync($"No public roles found. {(name == "" ? "" : $"Search: `{name}`")}\n`{Program.GetPrefix(Context)}spr` - make a role public.\n`{Program.GetPrefix(Context)}prl` - view a list of public roles.");

                return;
            }

            var guildUser = Context.User as SocketGuildUser;

            if (guildUser.Roles.Contains(role))
            {
                try
                {
                    await guildUser.RemoveRoleAsync(role);
                }
                catch
                {
                    await Context.Channel.SendMessageAsync($"I tried removing a role that is above my own role. *Coughs blood.* Discord wouldn't let me...");

                    return;
                }
                await Context.Channel.SendMessageAsync($"Removed the `{role.Name}` role from you. Don't come back, BAAAAAAAAAAAAAAKA!");
            }
            else
            {
                try
                {
                    await guildUser.AddRoleAsync(role);
                }
                catch
                {
                    await Context.Channel.SendMessageAsync($"I tried giving a role that is above my own role. *Coughs blood.* Discord wouldn't let me...");

                    return;
                }
                await Context.Channel.SendMessageAsync($"Gave you the `{role.Name}` role! Welcome to the club! o7");
            }
        }