diff options
author | TheArcaneBrony <myrainbowdash949@gmail.com> | 2022-09-04 10:07:23 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-09-04 10:07:23 +0200 |
commit | 9aeca6c03dac3ee76245d97eb66fef5f72fa0e71 (patch) | |
tree | f7585608f11523b6c5626df364267b67d71af489 | |
parent | Merge pull request #877 from DragonFire1230/staging (diff) | |
parent | Merge branch 'staging' into dev/Maddy/feat/welcomeMessages (diff) | |
download | server-9aeca6c03dac3ee76245d97eb66fef5f72fa0e71.tar.xz |
Merge pull request #874 from fosscord/dev/Maddy/feat/welcomeMessages
Welcome messages
-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 1b947a08..9e9131fe 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"; @@ -306,6 +306,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) + ]); + } } } |