summary refs log tree commit diff
diff options
context:
space:
mode:
authorRory& <root@rory.gay>2026-06-11 00:12:46 +0200
committerRory& <root@rory.gay>2026-06-11 00:12:46 +0200
commit6d9d3955bc43be203ab8696b18c19c69fb1242b2 (patch)
treec54c8b0aa2020f12772b39e9adb6ca3c54cc5c8d
parentHandle welcome message as insert + update (diff)
downloadserver-ts-6d9d3955bc43be203ab8696b18c19c69fb1242b2.tar.xz
Dont fetch entire channel for welcome message, dont fail if channel doesnt exist
-rw-r--r--src/util/entities/Member.ts11
1 files changed, 4 insertions, 7 deletions
diff --git a/src/util/entities/Member.ts b/src/util/entities/Member.ts

index 474e3e83..abbbdc14 100644 --- a/src/util/entities/Member.ts +++ b/src/util/entities/Member.ts
@@ -434,16 +434,13 @@ export class Member extends BaseClassWithoutId { ]); logTrace("Save member info"); - if (guild.system_channel_id) { - const channel = await Channel.findOneOrFail({ - where: { id: guild.system_channel_id }, - }); - + const welcomeChannelId = guild.system_channel_id; + if (welcomeChannelId && (await Channel.exists({ where: { id: welcomeChannelId } }))) { // Send a welcome message const message = Message.create({ type: 7, guild_id: guild.id, - channel_id: guild.system_channel_id, + channel_id: welcomeChannelId, author: user, timestamp: new Date(), reactions: [], @@ -465,7 +462,7 @@ export class Member extends BaseClassWithoutId { channel_id: message.channel_id, data: publicMsg, } satisfies MessageCreateEvent), - Channel.update({ id: channel.id }, { last_message_id: message.id }), + Channel.update({ id: welcomeChannelId }, { last_message_id: message.id }), ]); logTrace("Send welcome message"); }