File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1122,18 +1122,28 @@ export class Thread {
11221122 }
11231123
11241124 public async getDMChannel ( ) : Promise < DMChannel > {
1125- const user = await bot . users . fetch ( this . user_id ) ;
1126- const dmChannel = await user . createDM ( ) ;
1125+ try {
1126+ const user = await bot . users . fetch ( this . user_id ) ;
1127+ const dmChannel = await user . createDM ( ) ;
11271128
1128- return dmChannel ;
1129+ return dmChannel ;
1130+ } catch ( err ) {
1131+ logger . error ( { thread_id : this . id , user_id : this . user_id , err } ) ;
1132+ throw err ;
1133+ }
11291134 }
11301135
11311136 public async getThreadChannel ( ) : Promise < SendableChannels > {
1132- const channel = await bot . channels . fetch ( this . channel_id ) ;
1137+ try {
1138+ const channel = await bot . channels . fetch ( this . channel_id ) ;
11331139
1134- if ( channel ?. isSendable ( ) ) return channel ;
1140+ if ( channel ?. isSendable ( ) ) return channel ;
11351141
1136- throw "it was impossible to retrieve the thread channel" ;
1142+ throw "it was impossible to retrieve the thread channel" ;
1143+ } catch ( err ) {
1144+ logger . error ( { thread_id : this . id , user_id : this . user_id , err } ) ;
1145+ throw err ;
1146+ }
11371147 }
11381148
11391149 public async sendInfoHeader (
Original file line number Diff line number Diff line change @@ -168,10 +168,14 @@ export async function createNewThreadForUser(
168168 // We can safely discard this error, because it just means we couldn't find the member in the guild
169169 // Which - for obvious reasons - is completely okay.
170170 if ( ( e as DiscordAPIError ) . code !== 10007 ) {
171- logger . error ( {
171+ logger . debug ( {
172172 discord_api_code : ( e as DiscordAPIError ) . code ,
173173 err : e ,
174174 } ) ;
175+ } else {
176+ logger . error ( {
177+ err : e ,
178+ } ) ;
175179 }
176180 }
177181 }
Original file line number Diff line number Diff line change @@ -9,6 +9,7 @@ import { start } from "./main";
99import { migrateAllUp } from "./migrate" ;
1010import { PluginInstallationError } from "./PluginInstallationError" ;
1111import web from "./web" ;
12+ import logger from "./logger" ;
1213
1314const bunVersion = process . versions . bun . split ( "." ) . map ( parseInt ) as [
1415 number ,
@@ -112,6 +113,8 @@ modules.forEach((mod) => {
112113( async ( ) => {
113114 await migrateAllUp ( ) ;
114115
116+ logger . info ( `Pino opened on level ${ process . env . PINO_LOG_LEVEL } ` ) ;
117+
115118 // Start the bot
116119 start ( bot ) ;
117120
You can’t perform that action at this time.
0 commit comments