Permission pages
This commit is contained in:
parent
f41a8a1682
commit
c426a1709b
@ -65,7 +65,6 @@ namespace NadekoBot.Modules.CustomReactions
|
|||||||
}
|
}
|
||||||
|
|
||||||
[NadekoCommand, Usage, Description, Aliases]
|
[NadekoCommand, Usage, Description, Aliases]
|
||||||
[RequirePermission(GuildPermission.Administrator)]
|
|
||||||
public async Task AddCustReact(IUserMessage imsg, string key, [Remainder] string message)
|
public async Task AddCustReact(IUserMessage imsg, string key, [Remainder] string message)
|
||||||
{
|
{
|
||||||
var channel = imsg.Channel as ITextChannel;
|
var channel = imsg.Channel as ITextChannel;
|
||||||
@ -120,9 +119,9 @@ namespace NadekoBot.Modules.CustomReactions
|
|||||||
customReactions = GuildReactions.GetOrAdd(channel.Guild.Id, new HashSet<CustomReaction>());
|
customReactions = GuildReactions.GetOrAdd(channel.Guild.Id, new HashSet<CustomReaction>());
|
||||||
|
|
||||||
if (customReactions == null || !customReactions.Any())
|
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
|
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);
|
.ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -92,6 +92,8 @@ namespace NadekoBot.Modules.Permissions
|
|||||||
|
|
||||||
public static bool HasCooldown(Command cmd, IGuild guild, IUser user)
|
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>());
|
var cmdcds = CmdCdsCommands.commandCooldowns.GetOrAdd(guild.Id, new HashSet<CommandCooldown>());
|
||||||
CommandCooldown cdRule;
|
CommandCooldown cdRule;
|
||||||
if ((cdRule = cmdcds.FirstOrDefault(cc => cc.CommandName == cmd.Text.ToLowerInvariant())) != null)
|
if ((cdRule = cmdcds.FirstOrDefault(cc => cc.CommandName == cmd.Text.ToLowerInvariant())) != null)
|
||||||
|
@ -61,16 +61,18 @@ namespace NadekoBot.Modules.Permissions
|
|||||||
|
|
||||||
[NadekoCommand, Usage, Description, Aliases]
|
[NadekoCommand, Usage, Description, Aliases]
|
||||||
[RequireContext(ContextType.Guild)]
|
[RequireContext(ContextType.Guild)]
|
||||||
public async Task ListPerms(IUserMessage msg)
|
public async Task ListPerms(IUserMessage msg, int page = 1)
|
||||||
{
|
{
|
||||||
var channel = (ITextChannel)msg.Channel;
|
var channel = (ITextChannel)msg.Channel;
|
||||||
|
|
||||||
|
if (page < 1 || page > 4)
|
||||||
|
return;
|
||||||
string toSend = "";
|
string toSend = "";
|
||||||
using (var uow = DbHandler.UnitOfWork())
|
using (var uow = DbHandler.UnitOfWork())
|
||||||
{
|
{
|
||||||
var perms = uow.GuildConfigs.PermissionsFor(channel.Guild.Id).RootPermission;
|
var perms = uow.GuildConfigs.PermissionsFor(channel.Guild.Id).RootPermission;
|
||||||
var i = 1;
|
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))
|
if (string.IsNullOrWhiteSpace(toSend))
|
||||||
|
@ -3444,7 +3444,7 @@ namespace NadekoBot.Resources {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 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.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static string listperms_desc {
|
public static string listperms_desc {
|
||||||
get {
|
get {
|
||||||
@ -3453,7 +3453,7 @@ namespace NadekoBot.Resources {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Looks up a localized string similar to `;lp`.
|
/// Looks up a localized string similar to `;lp` or `;lp 3`.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static string listperms_usage {
|
public static string listperms_usage {
|
||||||
get {
|
get {
|
||||||
|
@ -2557,10 +2557,10 @@
|
|||||||
<value>cash $$</value>
|
<value>cash $$</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="listperms_desc" xml:space="preserve">
|
<data name="listperms_desc" xml:space="preserve">
|
||||||
<value>Lists whole permission chain with their indexes.</value>
|
<value>Lists whole permission chain with their indexes. You can specify optional page number if there are a lot of permissions</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="listperms_usage" xml:space="preserve">
|
<data name="listperms_usage" xml:space="preserve">
|
||||||
<value>`;lp`</value>
|
<value>`;lp` or `;lp 3`</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="listperms_cmd" xml:space="preserve">
|
<data name="listperms_cmd" xml:space="preserve">
|
||||||
<value>listperms lp</value>
|
<value>listperms lp</value>
|
||||||
|
@ -15,7 +15,7 @@ namespace NadekoBot.Services.Database.Models
|
|||||||
public string Response { get; set; }
|
public string Response { get; set; }
|
||||||
public string Trigger { get; set; }
|
public string Trigger { get; set; }
|
||||||
public bool IsRegex { 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
|
public class ReactionResponse : DbEntity
|
||||||
|
Loading…
Reference in New Issue
Block a user