diff options
-rw-r--r-- | src/util/entities/Member.ts | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/src/util/entities/Member.ts b/src/util/entities/Member.ts index 42a014d4..f67ec02c 100644 --- a/src/util/entities/Member.ts +++ b/src/util/entities/Member.ts @@ -1,6 +1,6 @@ import { Column, Entity, Index, JoinColumn, JoinTable, ManyToMany, ManyToOne, PrimaryGeneratedColumn, RelationId } from "typeorm"; -import { Ban, PublicGuildRelations } from "."; -import { GuildCreateEvent, GuildDeleteEvent, GuildMemberAddEvent, GuildMemberRemoveEvent, GuildMemberUpdateEvent } from "../interfaces"; +import { Ban, PublicGuildRelations, Message } from "."; +import { GuildCreateEvent, GuildDeleteEvent, GuildMemberAddEvent, GuildMemberRemoveEvent, GuildMemberUpdateEvent, MessageCreateEvent } from "../interfaces"; import { Config, emitEvent } from "../util"; import { DiscordApiErrors } from "../util/Constants"; import { HTTPError } from "../util/imports/HTTPError"; @@ -289,6 +289,27 @@ export class Member extends BaseClassWithoutId { user_id } as GuildCreateEvent) ]); + + if (guild.system_channel_id) { + // send welcome message + const message = OrmUtils.mergeDeep(new Message(), { + type: 7, + guild_id: guild.id, + channel_id: guild.system_channel_id, + author: user, + timestamp: new Date(), + + reactions: [], + attachments: [], + embeds: [], + sticker_items: [], + edited_timestamp: undefined, + }); + await Promise.all([ + message.save(), + emitEvent({ event: "MESSAGE_CREATE", channel_id: message.channel_id, data: message } as MessageCreateEvent) + ]); + } } } |