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()); }
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"); } }