From 2f66e03a0ff5dd07ea31145ae4d8b7b3d9f0a6e2 Mon Sep 17 00:00:00 2001 From: Erisa A Date: Sun, 7 Jul 2024 23:10:53 +0100 Subject: [PATCH] Add c!debug dumpdmchannels --- Commands/Debug.cs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/Commands/Debug.cs b/Commands/Debug.cs index 70369e08..d3df9b52 100644 --- a/Commands/Debug.cs +++ b/Commands/Debug.cs @@ -498,6 +498,27 @@ public async Task GetDMChannel(CommandContext ctx, DiscordUser user) await ctx.RespondAsync(dmChannel.Id.ToString()); } + [Command("dumpdmchannels")] + [Description("Dump all DM channels")] + [IsBotOwner] + public async Task DumpDMChannels(CommandContext ctx) + { + var dmChannels = ctx.Client.PrivateChannels; + + var json = JsonConvert.SerializeObject(dmChannels, Formatting.Indented); + + HasteBinResult hasteResult = await Program.hasteUploader.Post(json); + if (hasteResult.IsSuccess) + { + await ctx.RespondAsync(hasteResult.FullUrl); + } + else + { + Program.discord.Logger.LogError("Error ocurred uploading to Hastebin with status code: {code}\nPayload: {output}", hasteResult.StatusCode, json); + await ctx.RespondAsync($"{Program.cfgjson.Emoji.Error} Unknown error occurred during upload to Hastebin.\nPlease try again or contact the bot owner."); + } + } + private static async Task<(bool success, ulong failedOverwrite)> ImportOverridesFromChannelAsync(DiscordChannel channel) { // Imports overrides from the specified channel to the database. See 'debug overrides import' and 'debug overrides importall'