Skip to content

Commit 0e9aaaf

Browse files
Add 403 check to !debug overrides apply
1 parent 65f9e69 commit 0e9aaaf

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

Commands/Debug.cs

+12-3
Original file line numberDiff line numberDiff line change
@@ -446,6 +446,7 @@ public async Task Apply(CommandContext ctx,
446446
await msg.ModifyAsync($"{Program.cfgjson.Emoji.Error} {user.Mention} has no overrides to apply!");
447447
return;
448448
}
449+
var numAppliedOverrides = dictionary.Count;
449450

450451
foreach (var overwrite in dictionary)
451452
{
@@ -459,11 +460,19 @@ public async Task Apply(CommandContext ctx,
459460
continue;
460461
}
461462

462-
await channel.AddOverwriteAsync(member, overwrite.Value.Allowed, overwrite.Value.Denied,
463-
"Restoring saved overrides for member.");
463+
try
464+
{
465+
await channel.AddOverwriteAsync(member, overwrite.Value.Allowed, overwrite.Value.Denied, "Restoring saved overrides for member.");
466+
}
467+
catch (DSharpPlus.Exceptions.UnauthorizedException)
468+
{
469+
await ctx.RespondAsync($"{Program.cfgjson.Emoji.Error} I don't have permission to add overrides in {channel.Mention}! Continuing...");
470+
numAppliedOverrides--;
471+
}
472+
464473
}
465474

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

0 commit comments

Comments
 (0)