Skip to content

Commit e2b1ace

Browse files
committed
Update checks in various channel fetching routines
1 parent 741f5e1 commit e2b1ace

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

src/bot-utilities.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,18 +227,27 @@ export class BotUtilities {
227227

228228
async get_channel(id: string) {
229229
const channel = await this.wheatley.client.channels.fetch(id);
230+
if (!channel) {
231+
throw Error(`Channel ${id} not found`);
232+
}
230233
assert(channel instanceof Discord.TextChannel, `Channel ${channel} (${id}) not of the expected type`);
231234
return channel;
232235
}
233236

234237
async get_forum_channel(id: string) {
235238
const channel = await this.wheatley.client.channels.fetch(id);
239+
if (!channel) {
240+
throw Error(`Forum channel ${id} not found`);
241+
}
236242
assert(channel instanceof Discord.ForumChannel, `Channel ${channel} (${id}) not of the expected type`);
237243
return channel;
238244
}
239245

240246
async get_thread_channel(id: string) {
241247
const channel = await this.wheatley.client.channels.fetch(id);
248+
if (!channel) {
249+
throw Error(`Thread channel ${id} not found`);
250+
}
242251
assert(channel instanceof Discord.ThreadChannel, `Channel ${channel} (${id}) not of the expected type`);
243252
return channel;
244253
}

0 commit comments

Comments
 (0)