Skip to content

Commit

Permalink
Add OwnerOverride to SlashRequireHomeserverPerm & /send-insiders-info…
Browse files Browse the repository at this point in the history
…-buttons
  • Loading branch information
FloatingMilkshake committed Jan 1, 2025
1 parent c5f6411 commit baf81d9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
12 changes: 10 additions & 2 deletions CommandChecks/HomeServerPerms.cs
Original file line number Diff line number Diff line change
Expand Up @@ -137,14 +137,22 @@ public override async Task<bool> ExecuteCheckAsync(CommandContext ctx, bool help
public class SlashRequireHomeserverPermAttribute : SlashCheckBaseAttribute
{
public ServerPermLevel TargetLvl;
public bool OwnerOverride;

public SlashRequireHomeserverPermAttribute(ServerPermLevel targetlvl)
=> TargetLvl = targetlvl;
public SlashRequireHomeserverPermAttribute(ServerPermLevel targetlvl, bool ownerOverride = false)
{
TargetLvl = targetlvl;
OwnerOverride = ownerOverride;
}

public override async Task<bool> ExecuteChecksAsync(InteractionContext ctx)
{
if (ctx.Guild.Id != Program.cfgjson.ServerID)
return false;

// bot owners can bypass perm checks ONLY if the command allows it.
if (OwnerOverride && Program.cfgjson.BotOwners.Contains(ctx.User.Id))
return true;

var level = await GetPermLevelAsync(ctx.Member);
if (level >= TargetLvl)
Expand Down
2 changes: 1 addition & 1 deletion Commands/InteractionCommands/InsidersInteractions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ namespace Cliptok.Commands.InteractionCommands
public class InsidersInteractions : ApplicationCommandModule
{
[SlashCommand("send-insiders-info-buttons", "Sends a message with buttons to get Insider roles for #insiders-info.", false)]
[SlashRequireHomeserverPerm(ServerPermLevel.TrialModerator), SlashCommandPermissions(permissions: DiscordPermission.ModerateMembers)]
[SlashRequireHomeserverPerm(ServerPermLevel.Admin, ownerOverride: true), SlashCommandPermissions(permissions: DiscordPermission.ModerateMembers)]
public static async Task SendInsidersInfoButtonMessage(InteractionContext ctx)
{
if (Program.cfgjson.InsiderInfoChannel != 0 && ctx.Channel.Id != Program.cfgjson.InsiderInfoChannel)
Expand Down

0 comments on commit baf81d9

Please sign in to comment.