aboutsummaryrefslogtreecommitdiff
path: root/src/lib/models/Guild.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/models/Guild.ts')
-rw-r--r--src/lib/models/Guild.ts27
1 files changed, 26 insertions, 1 deletions
diff --git a/src/lib/models/Guild.ts b/src/lib/models/Guild.ts
index dfba90c..4640d70 100644
--- a/src/lib/models/Guild.ts
+++ b/src/lib/models/Guild.ts
@@ -16,6 +16,7 @@ export interface GuildModel {
lockdownChannels: Snowflake[];
autoModPhases: string[];
enabledFeatures: string[];
+ joinRoles: Snowflake[];
}
export interface GuildModelCreationAttributes {
@@ -31,6 +32,7 @@ export interface GuildModelCreationAttributes {
lockdownChannels?: Snowflake[];
autoModPhases?: string[];
enabledFeatures?: string[];
+ joinRoles?: Snowflake[];
}
export const guildSettings = {
@@ -39,10 +41,12 @@ export const guildSettings = {
welcomeChannel: { type: 'channel-array' },
muteRole: { type: 'role' },
punishmentEnding: { type: 'string' },
- lockdownChannels: { type: 'channel-array' }
+ lockdownChannels: { type: 'channel-array' },
+ joinRoles: { type: 'role-array' }
};
export const guildFeatures = ['automodEnabled', 'supportThreads', 'stickyRoles'];
+export type GuildFeatures = 'automodEnabled' | 'supportThreads' | 'stickyRoles';
const NEVER_USED = 'This should never be executed';
@@ -167,6 +171,16 @@ export class Guild extends BaseModel<GuildModel, GuildModelCreationAttributes> i
throw new Error(NEVER_USED);
}
+ /**
+ * The roles to assign to a user if they are not assigned sticky roles
+ */
+ public get joinRoles(): Snowflake[] {
+ throw new Error(NEVER_USED);
+ }
+ public set joinRoles(_: Snowflake[]) {
+ throw new Error(NEVER_USED);
+ }
+
public static initModel(sequelize: Sequelize, client: BushClient): void {
Guild.init(
{
@@ -267,6 +281,17 @@ export class Guild extends BaseModel<GuildModel, GuildModelCreationAttributes> i
},
allowNull: false,
defaultValue: '[]'
+ },
+ joinRoles: {
+ type: DataTypes.TEXT,
+ get: function () {
+ return JSON.parse(this.getDataValue('enabledFeatures') as unknown as string);
+ },
+ set: function (val: string[]) {
+ return this.setDataValue('enabledFeatures', JSON.stringify(val) as unknown as string[]);
+ },
+ allowNull: false,
+ defaultValue: '[]'
}
},
{ sequelize: sequelize }