diff --git a/src/NadekoBot/Modules/CustomReactions/CustomReactions.cs b/src/NadekoBot/Modules/CustomReactions/CustomReactions.cs index e634921f..7e84b2e3 100644 --- a/src/NadekoBot/Modules/CustomReactions/CustomReactions.cs +++ b/src/NadekoBot/Modules/CustomReactions/CustomReactions.cs @@ -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()); 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); } diff --git a/src/NadekoBot/Modules/Permissions/Commands/CmdCdsCommands.cs b/src/NadekoBot/Modules/Permissions/Commands/CmdCdsCommands.cs index b14fd452..d1f8ea51 100644 --- a/src/NadekoBot/Modules/Permissions/Commands/CmdCdsCommands.cs +++ b/src/NadekoBot/Modules/Permissions/Commands/CmdCdsCommands.cs @@ -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 cdRule; if ((cdRule = cmdcds.FirstOrDefault(cc => cc.CommandName == cmd.Text.ToLowerInvariant())) != null) diff --git a/src/NadekoBot/Modules/Permissions/Permissions.cs b/src/NadekoBot/Modules/Permissions/Permissions.cs index 94ba7ebb..d8e2d167 100644 --- a/src/NadekoBot/Modules/Permissions/Permissions.cs +++ b/src/NadekoBot/Modules/Permissions/Permissions.cs @@ -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)) diff --git a/src/NadekoBot/Resources/CommandStrings.Designer.cs b/src/NadekoBot/Resources/CommandStrings.Designer.cs index 2aff97ab..074519bc 100644 --- a/src/NadekoBot/Resources/CommandStrings.Designer.cs +++ b/src/NadekoBot/Resources/CommandStrings.Designer.cs @@ -3444,7 +3444,7 @@ namespace NadekoBot.Resources { } /// - /// Looks up a localized string similar to Lists whole permission chain with their indexes.. + /// Looks up a localized string similar to Lists whole permission chain with their indexes. You can specify optional page number if there are a lot of permissions. /// public static string listperms_desc { get { @@ -3453,7 +3453,7 @@ namespace NadekoBot.Resources { } /// - /// Looks up a localized string similar to `;lp`. + /// Looks up a localized string similar to `;lp` or `;lp 3`. /// public static string listperms_usage { get { diff --git a/src/NadekoBot/Resources/CommandStrings.resx b/src/NadekoBot/Resources/CommandStrings.resx index 47bae782..8b5ee7e4 100644 --- a/src/NadekoBot/Resources/CommandStrings.resx +++ b/src/NadekoBot/Resources/CommandStrings.resx @@ -2557,10 +2557,10 @@ cash $$ - Lists whole permission chain with their indexes. + Lists whole permission chain with their indexes. You can specify optional page number if there are a lot of permissions - `;lp` + `;lp` or `;lp 3` listperms lp diff --git a/src/NadekoBot/Services/Database/Models/CustomReaction.cs b/src/NadekoBot/Services/Database/Models/CustomReaction.cs index 180b85b9..d6f061c1 100644 --- a/src/NadekoBot/Services/Database/Models/CustomReaction.cs +++ b/src/NadekoBot/Services/Database/Models/CustomReaction.cs @@ -15,7 +15,7 @@ namespace NadekoBot.Services.Database.Models public string Response { get; set; } public string Trigger { get; set; } public bool IsRegex { get; set; } - public override string ToString() => $"Id: {Id}\nTrigger: {Trigger}\n Regex: {IsRegex}"; + public override string ToString() => $"`#{Id}` `Trigger:` {Trigger}\n `Response:` {Response}"; } public class ReactionResponse : DbEntity