.btr and .sclr added, cleanup

This commit is contained in:
Kwoth
2024-11-20 17:14:48 +00:00
parent 3178074828
commit 796086538a
119 changed files with 9154 additions and 646 deletions

View File

@@ -27,6 +27,9 @@ public abstract class NadekoModule : ModuleBase
protected ICommandContext ctx
=> Context;
protected EmbedBuilder CreateEmbed()
=> _sender.CreateEmbed(ctx.Guild?.Id);
public ResponseBuilder Response()
=> new ResponseBuilder(Strings, _bcs, (DiscordSocketClient)ctx.Client)
.Context(ctx);
@@ -91,7 +94,7 @@ public abstract class NadekoModule : ModuleBase
if (validate is not null && !validate(arg.Content))
return Task.CompletedTask;
if (userInputTask.TrySetResult(arg.Content))
userMsg.DeleteAfter(1);
@@ -100,7 +103,7 @@ public abstract class NadekoModule : ModuleBase
return Task.CompletedTask;
}
}
protected async Task<bool> CheckRoleHierarchy(IGuildUser target)
{
var curUser = ((SocketGuild)ctx.Guild).CurrentUser;
@@ -121,6 +124,25 @@ public abstract class NadekoModule : ModuleBase
return true;
}
protected async Task<bool> CheckRoleHierarchy(IRole role)
{
var botUser = ((SocketGuild)ctx.Guild).CurrentUser;
var ownerId = ctx.Guild.OwnerId;
var modMaxRole = ((IGuildUser)ctx.User).GetRoles().Max(r => r.Position);
var botMaxRole = botUser.GetRoles().Max(r => r.Position);
// role must be lower than the bot role
// and the mod must have a higher role
if (botMaxRole <= role.Position
|| (ctx.User.Id != ownerId && role.Position >= modMaxRole))
{
await Response().Error(strs.hierarchy).SendAsync();
return false;
}
return true;
}
}
public abstract class NadekoModule<TService> : NadekoModule