ItzDerock / discord-html-transcripts

A node.js library for generating nicely formatted HTML transcripts with discord.js
http://npmjs.org/package/discord-html-transcripts
Apache License 2.0
207 stars 81 forks source link

Deleted channel mentions causes it to error #76

Closed MX1D closed 2 years ago

MX1D commented 2 years ago

If one of the messages included a mention for a deleted/invalid channel it would make it error, here's an example of the error

rawError: { message: 'Unknown Channel', code: 10003 },
   code: 10003,
   status: 404,
   method: 'GET',
   url: 'https://discord.com/api/v10/channels/997048704513085500',
   requestBody: { files: undefined, json: undefined }
 } Promise {
   <rejected> DiscordAPIError[10003]: Unknown Channel
       at SequentialHandler.runRequest (D:FoldersJavascript
ajk
ode_modules@discordjs
estdistlibhandlersSequentialHandler.cjs:293:15)
       at processTicksAndRejections (node:internal/process/task_queues:96:5)
       at async SequentialHandler.queueRequest (D:FoldersJavascript
ajk
ode_modules@discordjs
estdistlibhandlersSequentialHandler.cjs:99:14)
       at async REST.request (D:FoldersJavascript
ajk
ode_modules@discordjs
estdistlibREST.cjs:52:22)
       at async GuildChannelManager.fetch (D:FoldersJavascript
ajk
ode_modulesdiscord.jssrcmanagersGuildChannelManager.js:339:20)
       at async file:///D:/Folders/Javascript/rajk/src/slashCommands/archive.js:49:41 {
     rawError: { message: 'Unknown Channel', code: 10003 },
     code: 10003,
     status: 404,
     method: 'GET',
     url: 'https://discord.com/api/v10/channels/997048704513085500',
     requestBody: { files: undefined, json: undefined }
   }
}
ItzDerock commented 2 years ago

Until I get around to fixing this, you can set custom callbacks that are patched, just use the following callbacks option:


callbacks: {
    resolveChannel: (id) => client.channels.fetch(id).catch(err => null),
    resolveUser: (id) => client.users.fetch(id).catch(err => null),
    resolveRole: channel.isDMBased() ? () => null : async (id) => channel.guild?.roles.fetch(id).catch(err => null),
}
ItzDerock commented 2 years ago

fixed in 3.1.0