mirror of
https://github.com/spacebarchat/server.git
synced 2026-10-23 02:13:00 +00:00
Fix loading discord guild templates
This commit is contained in:
1 parent
c1679ec394
commit
3c844ae777
6 files changed
+46
-9
No files matched your search
@@ -218,7 +218,10 @@ export class Channel extends BaseClass {
|
||||
for (const character of InvisibleCharacters) if (channel.name.includes(character)) throw new HTTPError("Channel name cannot include invalid characters", 403);
|
||||
|
||||
// Categories skip these checks on discord.com
|
||||
if (channel.type !== ChannelType.GUILD_CATEGORY || guild.features.includes("IRC_LIKE_CATEGORY_NAMES")) {
|
||||
if (
|
||||
(channel.type !== ChannelType.GUILD_CATEGORY && channel.type !== ChannelType.GUILD_STAGE_VOICE && channel.type !== ChannelType.GUILD_VOICE) ||
|
||||
guild.features.includes("IRC_LIKE_CATEGORY_NAMES")
|
||||
) {
|
||||
if (channel.name.includes(" ")) throw new HTTPError("Channel name cannot include invalid characters", 403);
|
||||
|
||||
if (channel.name.match(/--+/g)) throw new HTTPError("Channel name cannot include multiple adjacent dashes.", 403);
|
||||
|
||||
@@ -310,7 +310,7 @@ export class Guild extends BaseClass {
|
||||
owner_id?: string;
|
||||
roles?: Partial<Role>[];
|
||||
channels?: Partial<Channel>[];
|
||||
template_guild_id: string | null;
|
||||
source_guild_id: string | null;
|
||||
}) {
|
||||
const guild_id = Snowflake.generate();
|
||||
|
||||
@@ -372,7 +372,7 @@ export class Guild extends BaseClass {
|
||||
guild_id,
|
||||
id:
|
||||
// role.id === body.template_guild_id indicates that this is the @everyone role
|
||||
role.id === body.template_guild_id ? guild_id : Snowflake.generate(),
|
||||
role.id === body.source_guild_id || role.id == "0" ? guild_id : Snowflake.generate(),
|
||||
})
|
||||
.save()
|
||||
.then(resolve);
|
||||
|
||||
@@ -42,7 +42,7 @@ export class Role extends BaseClass {
|
||||
@Column()
|
||||
hoist: boolean;
|
||||
|
||||
@Column()
|
||||
@Column({ default: false })
|
||||
managed: boolean;
|
||||
|
||||
@Column()
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
import { MigrationInterface, QueryRunner } from "typeorm";
|
||||
|
||||
export class SetRoleManagedDefault1771271159006 implements MigrationInterface {
|
||||
name = "SetRoleManagedDefault1771271159006";
|
||||
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`ALTER TABLE "roles" ALTER COLUMN "managed" SET DEFAULT false`);
|
||||
}
|
||||
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`ALTER TABLE "roles" ALTER COLUMN "managed" DROP DEFAULT`);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user