aboutsummaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/extensions/discord-akairo/BushClientUtil.ts3
-rw-r--r--src/lib/extensions/discord.js/BushGuild.ts2
-rw-r--r--src/lib/models/Guild.ts4
3 files changed, 6 insertions, 3 deletions
diff --git a/src/lib/extensions/discord-akairo/BushClientUtil.ts b/src/lib/extensions/discord-akairo/BushClientUtil.ts
index 29be84c..3c3a9c4 100644
--- a/src/lib/extensions/discord-akairo/BushClientUtil.ts
+++ b/src/lib/extensions/discord-akairo/BushClientUtil.ts
@@ -996,7 +996,8 @@ export class BushClientUtil extends ClientUtil {
return await row.save().catch((e) => client.logger.error('insertOrRemoveFromGlobal', e?.stack || e));
}
- public addOrRemoveFromArray(action: 'add' | 'remove', array: any[], value: any): any[] {
+ public addOrRemoveFromArray(action: 'add' | 'remove', _array: any[], value: any): any[] {
+ const array = new Array(..._array); // prevent modifying the original array
let newValue: any[];
if (!array) throw new Error('array is either null or undefined');
if (action === 'add') {
diff --git a/src/lib/extensions/discord.js/BushGuild.ts b/src/lib/extensions/discord.js/BushGuild.ts
index efc780d..908fcec 100644
--- a/src/lib/extensions/discord.js/BushGuild.ts
+++ b/src/lib/extensions/discord.js/BushGuild.ts
@@ -21,6 +21,7 @@ export class BushGuild extends Guild {
}
public async getSetting<K extends keyof GuildModel>(setting: K): Promise<GuildModel[K]> {
+ // client.console.debug(`getSetting: ${setting}`);
return (
client.cache.guilds.get(this.id)?.[setting] ??
((await GuildDB.findByPk(this.id)) ?? GuildDB.build({ id: this.id }))[setting]
@@ -28,6 +29,7 @@ export class BushGuild extends Guild {
}
public async setSetting<K extends keyof GuildModel>(setting: K, value: GuildDB[K]): Promise<GuildDB> {
+ // client.console.debug(`setSetting: ${setting}`);
const row = (await GuildDB.findByPk(this.id)) ?? GuildDB.build({ id: this.id });
row[setting] = value;
client.cache.guilds.set(this.id, row.toJSON() as GuildDB);
diff --git a/src/lib/models/Guild.ts b/src/lib/models/Guild.ts
index 4640d70..41ded9d 100644
--- a/src/lib/models/Guild.ts
+++ b/src/lib/models/Guild.ts
@@ -285,10 +285,10 @@ export class Guild extends BaseModel<GuildModel, GuildModelCreationAttributes> i
joinRoles: {
type: DataTypes.TEXT,
get: function () {
- return JSON.parse(this.getDataValue('enabledFeatures') as unknown as string);
+ return JSON.parse(this.getDataValue('joinRoles') as unknown as string);
},
set: function (val: string[]) {
- return this.setDataValue('enabledFeatures', JSON.stringify(val) as unknown as string[]);
+ return this.setDataValue('joinRoles', JSON.stringify(val) as unknown as string[]);
},
allowNull: false,
defaultValue: '[]'