Permission pages
This commit is contained in:
@@ -65,7 +65,6 @@ namespace NadekoBot.Modules.CustomReactions
|
||||
}
|
||||
|
||||
[NadekoCommand, Usage, Description, Aliases]
|
||||
[RequirePermission(GuildPermission.Administrator)]
|
||||
public async Task AddCustReact(IUserMessage imsg, string key, [Remainder] string message)
|
||||
{
|
||||
var channel = imsg.Channel as ITextChannel;
|
||||
@@ -120,9 +119,9 @@ namespace NadekoBot.Modules.CustomReactions
|
||||
customReactions = GuildReactions.GetOrAdd(channel.Guild.Id, new HashSet<CustomReaction>());
|
||||
|
||||
if (customReactions == null || !customReactions.Any())
|
||||
await channel.SendMessageAsync("`No custom reactions found`").ConfigureAwait(false);
|
||||
await imsg.Channel.SendMessageAsync("`No custom reactions found`").ConfigureAwait(false);
|
||||
else
|
||||
await channel.SendTableAsync(customReactions.OrderBy(cr => cr.Trigger).Skip((page - 1) * 10).Take(10), c => c.ToString())
|
||||
await imsg.Channel.SendMessageAsync(string.Join("\n", customReactions.OrderBy(cr => cr.Trigger).Skip((page - 1) * 10).Take(10)))
|
||||
.ConfigureAwait(false);
|
||||
}
|
||||
|
||||
|
@@ -92,6 +92,8 @@ namespace NadekoBot.Modules.Permissions
|
||||
|
||||
public static bool HasCooldown(Command cmd, IGuild guild, IUser user)
|
||||
{
|
||||
if (guild == null)
|
||||
return false;
|
||||
var cmdcds = CmdCdsCommands.commandCooldowns.GetOrAdd(guild.Id, new HashSet<CommandCooldown>());
|
||||
CommandCooldown cdRule;
|
||||
if ((cdRule = cmdcds.FirstOrDefault(cc => cc.CommandName == cmd.Text.ToLowerInvariant())) != null)
|
||||
|
@@ -61,16 +61,18 @@ namespace NadekoBot.Modules.Permissions
|
||||
|
||||
[NadekoCommand, Usage, Description, Aliases]
|
||||
[RequireContext(ContextType.Guild)]
|
||||
public async Task ListPerms(IUserMessage msg)
|
||||
public async Task ListPerms(IUserMessage msg, int page = 1)
|
||||
{
|
||||
var channel = (ITextChannel)msg.Channel;
|
||||
|
||||
if (page < 1 || page > 4)
|
||||
return;
|
||||
string toSend = "";
|
||||
using (var uow = DbHandler.UnitOfWork())
|
||||
{
|
||||
var perms = uow.GuildConfigs.PermissionsFor(channel.Guild.Id).RootPermission;
|
||||
var i = 1;
|
||||
toSend = String.Join("\n", perms.AsEnumerable().Select(p => $"`{(i++)}.` {(p.Next == null ? Format.Bold(p.GetCommand(channel.Guild) + " [uneditable]") : (p.GetCommand(channel.Guild)))}"));
|
||||
toSend = Format.Code($"Permissions page {page}") + "\n\n" + String.Join("\n", perms.AsEnumerable().Skip((page - 1) * 20).Take(20).Select(p => $"`{(i++)}.` {(p.Next == null ? Format.Bold(p.GetCommand(channel.Guild) + " [uneditable]") : (p.GetCommand(channel.Guild)))}"));
|
||||
}
|
||||
|
||||
if (string.IsNullOrWhiteSpace(toSend))
|
||||
|
Reference in New Issue
Block a user