Skip to content

Commit

Permalink
Add 403 check to !debug overrides apply
Browse files Browse the repository at this point in the history
  • Loading branch information
FloatingMilkshake committed Aug 7, 2024
1 parent 65f9e69 commit 0e9aaaf
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions Commands/Debug.cs
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,7 @@ public async Task Apply(CommandContext ctx,
await msg.ModifyAsync($"{Program.cfgjson.Emoji.Error} {user.Mention} has no overrides to apply!");
return;
}
var numAppliedOverrides = dictionary.Count;

foreach (var overwrite in dictionary)
{
Expand All @@ -459,11 +460,19 @@ public async Task Apply(CommandContext ctx,
continue;
}

await channel.AddOverwriteAsync(member, overwrite.Value.Allowed, overwrite.Value.Denied,
"Restoring saved overrides for member.");
try
{
await channel.AddOverwriteAsync(member, overwrite.Value.Allowed, overwrite.Value.Denied, "Restoring saved overrides for member.");
}
catch (DSharpPlus.Exceptions.UnauthorizedException)
{
await ctx.RespondAsync($"{Program.cfgjson.Emoji.Error} I don't have permission to add overrides in {channel.Mention}! Continuing...");
numAppliedOverrides--;
}

}

await msg.ModifyAsync(x => x.Content = $"{Program.cfgjson.Emoji.Success} Successfully applied {dictionary.Count} overrides for {user.Mention}!");
await msg.ModifyAsync(x => x.Content = $"{Program.cfgjson.Emoji.Success} Successfully applied {numAppliedOverrides}/{dictionary.Count} overrides for {user.Mention}!");
}
}

Expand Down

0 comments on commit 0e9aaaf

Please sign in to comment.