public async Task SetChannelRoleAsync([Remainder] string input = "") { if (!StateChecker.IsGuildAdmin(Context)) { await Context.Channel.SendMessageAsync(":x: You are not guild admin!"); return; } if (StateChecker.IsPrivateMessage(Context)) { await Context.Channel.SendMessageAsync( ":x: Please use this command in the channel you wish to set the role for"); } var roleHandler = new RoleHandler(Factory.GetDatabase()); if (!roleHandler.IsValidRole(input)) { await Context.Channel.SendMessageAsync($":x: *{input}* is not a valid channel role"); return; } roleHandler.SetRoleForChannel(Context.Channel.Id, input); await Context.Channel.SendMessageAsync( $"This channel has now been set to the *{input.ToLower()}* role!"); }
public async Task ShowChannelRolesAsync() { if (!StateChecker.IsGuildAdmin(Context)) { await Context.Channel.SendMessageAsync(":x: You are not guild admin!"); return; } if (StateChecker.IsPrivateMessage(Context)) { await Context.Channel.SendMessageAsync( ":x: Please use this command in the guild you wish to see the roles for"); } var roleHandler = new RoleHandler(Factory.GetDatabase()); var allGuildTextChannels = Context.Guild.TextChannels; var botUserId = Context.Client.CurrentUser.Id; foreach (var guildChannel in allGuildTextChannels) { var users = guildChannel.Users; foreach (var user in users) { if (user.Id == botUserId) { var role = roleHandler.GetRoleForChannel(guildChannel.Id); await Context.Channel.SendMessageAsync($"{guildChannel.Name} : {role}"); } } } }
public async Task ClearChannelRoleAsync() { if (!StateChecker.IsGuildAdmin(Context)) { await Context.Channel.SendMessageAsync(":x: You are not guild admin!"); return; } if (StateChecker.IsPrivateMessage(Context)) { await Context.Channel.SendMessageAsync( ":x: Please use this command in the channel you wish to clear the role for"); } var roleHandler = new RoleHandler(Factory.GetDatabase()); roleHandler.ClearRoleForChannel(Context.Channel.Id); }