Skip to content

Commit

Permalink
Add !debug dumpchanneloverrides
Browse files Browse the repository at this point in the history
  • Loading branch information
FloatingMilkshake committed Jul 4, 2024
1 parent 92f9d63 commit 0999081
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions Commands/Debug.cs
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,39 @@ public async Task ImportAll(CommandContext ctx)
await ctx.RespondAsync($"{Program.cfgjson.Emoji.Success} Overrides for {user.Mention} in {channel.Mention} removed successfully!");
}
}

[Command("dumpchanneloverrides")]
[Description("Dump all of a channel's overrides. This pulls from Discord, not the database.")]
[IsBotOwner]
public async Task DumpChannelOverrides(CommandContext ctx,
[Description("The channel to dump overrides for.")] DiscordChannel channel)
{
var overwrites = channel.PermissionOverwrites;

string output = "";
foreach (var overwrite in overwrites)
{
output += $"{JsonConvert.SerializeObject(overwrite)}\n";
}

if (output.Length > 1990)
{
HasteBinResult hasteResult = await Program.hasteUploader.Post(output);
if (hasteResult.IsSuccess)
{
await ctx.RespondAsync($"{Program.cfgjson.Emoji.Warning} Output exceeded character limit: {hasteResult.FullUrl}.json");
}
else
{
Console.WriteLine(output);
await ctx.RespondAsync($"{Program.cfgjson.Emoji.Error} Unknown error occurred during upload to Hastebin.\nPlease try again or contact the bot owner.");
}
}
else
{
await ctx.RespondAsync($"```\n{output}\n```");
}
}

[Command("dmchannel")]
[Description("Create or find a DM channel ID for a user.")]
Expand Down

0 comments on commit 0999081

Please sign in to comment.