summary refs log tree commit diff
diff options
context:
space:
mode:
authorCyber <cyber.hf18@gmail.com>2025-11-18 07:23:25 +0100
committerGitHub <noreply@github.com>2025-11-18 07:23:25 +0100
commitf20ad063033ccf206da48b62caee1298d8449208 (patch)
treeda47d07b139f4bf80bf590a511772400f2040e46
parentfix greet API (diff)
parentMerge pull request #1384 from MathMan05/welcomeUpdate (diff)
downloadserver-ts-f20ad063033ccf206da48b62caee1298d8449208.tar.xz
Merge branch 'master' into greetFix
-rw-r--r--.gitignore3
-rw-r--r--src/api/routes/channels/#channel_id/greet.ts3
-rw-r--r--src/util/config/types/subconfigurations/guild/AutoJoin.ts1
-rw-r--r--src/util/entities/Member.ts7
-rw-r--r--src/util/entities/User.ts11
-rw-r--r--src/util/util/Application.ts1
6 files changed, 24 insertions, 2 deletions
diff --git a/.gitignore b/.gitignore

index 902ed77c..dc33551a 100644 --- a/.gitignore +++ b/.gitignore
@@ -20,4 +20,5 @@ build tmp/ dump/ result -jwt.key* \ No newline at end of file +jwt.key* +bun.lock diff --git a/src/api/routes/channels/#channel_id/greet.ts b/src/api/routes/channels/#channel_id/greet.ts
index 92efcca3..94a8f343 100644 --- a/src/api/routes/channels/#channel_id/greet.ts +++ b/src/api/routes/channels/#channel_id/greet.ts
@@ -88,6 +88,8 @@ router.post( sticker_items: randomSticker ? [{ id: randomSticker.id, name: randomSticker.name, format_type: randomSticker.format_type }] : [], }); + channel.last_message_id = message.id; + await Promise.all([ message.save(), emitEvent({ @@ -95,6 +97,7 @@ router.post( data: message, channel_id, } as MessageCreateEvent), + channel.save(), ]); res.send(message); diff --git a/src/util/config/types/subconfigurations/guild/AutoJoin.ts b/src/util/config/types/subconfigurations/guild/AutoJoin.ts
index be1c0d0d..5acdd74e 100644 --- a/src/util/config/types/subconfigurations/guild/AutoJoin.ts +++ b/src/util/config/types/subconfigurations/guild/AutoJoin.ts
@@ -20,4 +20,5 @@ export class AutoJoinConfiguration { enabled: boolean = true; guilds: string[] = []; canLeave: boolean = true; + bots: boolean = false; } diff --git a/src/util/entities/Member.ts b/src/util/entities/Member.ts
index 98f6e687..7cfe844b 100644 --- a/src/util/entities/Member.ts +++ b/src/util/entities/Member.ts
@@ -397,6 +397,9 @@ export class Member extends BaseClassWithoutId { ]); if (guild.system_channel_id) { + const channel = await Channel.findOneOrFail({ + where: { id: guild.system_channel_id }, + }); // Send a welcome message const message = Message.create({ type: 7, @@ -414,6 +417,9 @@ export class Member extends BaseClassWithoutId { mention_roles: [], mention_everyone: false, }); + + channel.last_message_id = message.id; + await Promise.all([ message.save(), emitEvent({ @@ -421,6 +427,7 @@ export class Member extends BaseClassWithoutId { channel_id: message.channel_id, data: message, } as MessageCreateEvent), + channel.save(), ]); } } diff --git a/src/util/entities/User.ts b/src/util/entities/User.ts
index eb42d9f2..5ee63352 100644 --- a/src/util/entities/User.ts +++ b/src/util/entities/User.ts
@@ -157,7 +157,7 @@ export class User extends BaseClass { @OneToOne(() => UserSettings, { cascade: true, orphanedRowAction: "delete", - nullable: true + nullable: true, }) @JoinColumn() settings?: UserSettings; @@ -257,6 +257,7 @@ export class User extends BaseClass { password, id, req, + bot, }: { username: string; password?: string; @@ -264,6 +265,7 @@ export class User extends BaseClass { date_of_birth?: Date; // "2000-04-03" id?: string; req?: Request; + bot?: boolean; }) { // trim special uf8 control characters -> Backspace, Newline, ... username = trimSpecial(username); @@ -306,6 +308,7 @@ export class User extends BaseClass { premium_type: Config.get().defaults.user.premiumType ?? 0, verified: Config.get().defaults.user.verified ?? true, created_at: new Date(), + bot: !!bot, }); user.validate(); @@ -319,6 +322,12 @@ export class User extends BaseClass { } setImmediate(async () => { + if (bot) { + const { guild } = Config.get(); + if (!guild.autoJoin.bots) { + return; + } + } if (Config.get().guild.autoJoin.enabled) { for (const guild of Config.get().guild.autoJoin.guilds || []) { await Member.addToGuild(user.id, guild).catch((e) => console.error("[Autojoin]", e)); diff --git a/src/util/util/Application.ts b/src/util/util/Application.ts
index 23019a7f..35cf6a37 100644 --- a/src/util/util/Application.ts +++ b/src/util/util/Application.ts
@@ -7,6 +7,7 @@ export async function createAppBotUser(app: Application, req: Request) { password: undefined, id: app.id, req, + bot: true, }); user.id = app.id;