aboutsummaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/extensions/discord-akairo/BushClientUtil.ts8
-rw-r--r--src/lib/extensions/discord-akairo/BushSlashMessage.ts5
-rw-r--r--src/lib/models/Guild.ts4
-rw-r--r--src/lib/models/ModLog.ts8
-rw-r--r--src/lib/models/__helpers.ts12
5 files changed, 18 insertions, 19 deletions
diff --git a/src/lib/extensions/discord-akairo/BushClientUtil.ts b/src/lib/extensions/discord-akairo/BushClientUtil.ts
index c15ca1c..5a71167 100644
--- a/src/lib/extensions/discord-akairo/BushClientUtil.ts
+++ b/src/lib/extensions/discord-akairo/BushClientUtil.ts
@@ -51,7 +51,6 @@ import got from 'got';
import humanizeDuration from 'humanize-duration';
import _ from 'lodash';
import moment from 'moment';
-import fetch from 'node-fetch';
import { inspect, InspectOptions, promisify } from 'util';
import CommandErrorListener from '../../../listeners/commands/commandError';
import { ActivePunishment, ActivePunishmentType } from '../../models/ActivePunishment';
@@ -1466,9 +1465,10 @@ export class BushClientUtil extends ClientUtil {
public async getPronounsOf(user: User | Snowflake): Promise<Pronoun | undefined> {
const _user = await this.resolveNonCachedUser(user);
if (!_user) throw new Error(`Cannot find user ${user}`);
- const apiRes: { pronouns: PronounCode } | undefined = await fetch(
- `https://pronoundb.org/api/v1/lookup?platform=discord&id=${_user.id}`
- ).then(async (r) => (r.ok ? ((await r.json()) as { pronouns: PronounCode }) : undefined));
+ const apiRes = (await got
+ .get(`https://pronoundb.org/api/v1/lookup?platform=discord&id=${_user.id}`)
+ .json()
+ .catch(() => undefined)) as { pronouns: PronounCode } | undefined;
if (!apiRes) return undefined;
if (!apiRes.pronouns) throw new Error('apiRes.pronouns is undefined');
diff --git a/src/lib/extensions/discord-akairo/BushSlashMessage.ts b/src/lib/extensions/discord-akairo/BushSlashMessage.ts
index 442b0d4..d75d0a7 100644
--- a/src/lib/extensions/discord-akairo/BushSlashMessage.ts
+++ b/src/lib/extensions/discord-akairo/BushSlashMessage.ts
@@ -4,7 +4,6 @@ import { BushGuild } from '../discord.js/BushGuild';
import { BushGuildMember } from '../discord.js/BushGuildMember';
import { BushUser } from '../discord.js/BushUser';
import { BushClient } from './BushClient';
-import { BushCommand } from './BushCommand';
import { BushCommandUtil } from './BushCommandUtil';
export class BushSlashMessage extends AkairoMessage {
@@ -12,8 +11,8 @@ export class BushSlashMessage extends AkairoMessage {
public declare util: BushCommandUtil;
public declare author: BushUser;
public declare member: BushGuildMember | null;
- public constructor(client: BushClient, interaction: CommandInteraction, command: BushCommand) {
- super(client, interaction, command);
+ public constructor(client: BushClient, interaction: CommandInteraction) {
+ super(client, interaction);
}
public override get guild(): BushGuild | null {
diff --git a/src/lib/models/Guild.ts b/src/lib/models/Guild.ts
index 9b283ab..f59bed1 100644
--- a/src/lib/models/Guild.ts
+++ b/src/lib/models/Guild.ts
@@ -355,10 +355,10 @@ export class Guild extends BaseModel<GuildModel, GuildModelCreationAttributes> i
logChannels: {
type: DataTypes.TEXT,
get: function (): LogChannelDB {
- return jsonParseGet('logChannels', this);
+ return jsonParseGet.call(this, 'logChannels');
},
set: function (val: LogChannelDB) {
- return jsonParseSet('logChannels', this, val);
+ return jsonParseSet.call(this, 'logChannels', val);
},
allowNull: false,
defaultValue: '{}'
diff --git a/src/lib/models/ModLog.ts b/src/lib/models/ModLog.ts
index a70913d..3675649 100644
--- a/src/lib/models/ModLog.ts
+++ b/src/lib/models/ModLog.ts
@@ -191,10 +191,10 @@ export class ModLog extends BaseModel<ModLogModel, ModLogModelCreationAttributes
pseudo: {
type: DataTypes.STRING,
get: function (): boolean {
- return jsonParseGet('pseudo', this);
+ return jsonParseGet.call(this, 'pseudo');
},
set: function (val: boolean) {
- return jsonParseSet('pseudo', this, val);
+ return jsonParseSet.call(this, 'pseudo', val);
},
allowNull: false,
defaultValue: 'false'
@@ -202,10 +202,10 @@ export class ModLog extends BaseModel<ModLogModel, ModLogModelCreationAttributes
hidden: {
type: DataTypes.STRING,
get: function (): boolean {
- return jsonParseGet('hidden', this);
+ return jsonParseGet.call(this, 'hidden');
},
set: function (val: boolean) {
- return jsonParseSet('hidden', this, val);
+ return jsonParseSet.call(this, 'hidden', val);
},
allowNull: false,
defaultValue: 'false'
diff --git a/src/lib/models/__helpers.ts b/src/lib/models/__helpers.ts
index b65c014..243b274 100644
--- a/src/lib/models/__helpers.ts
+++ b/src/lib/models/__helpers.ts
@@ -1,21 +1,21 @@
import { DataTypes, Model } from 'sequelize';
export const NEVER_USED = 'This should never be executed';
-export function jsonParseGet(key: string, that: Model): any {
- return JSON.parse(that.getDataValue(key));
+export function jsonParseGet(this: Model, key: string): any {
+ return JSON.parse(this.getDataValue(key));
}
-export function jsonParseSet(key: string, that: Model, value: any): any {
- return that.setDataValue(key, JSON.stringify(value));
+export function jsonParseSet(this: Model, key: string, value: any): any {
+ return this.setDataValue(key, JSON.stringify(value));
}
export function jsonArrayInit(key: string): any {
return {
type: DataTypes.TEXT,
get: function (): string[] {
- return jsonParseGet(key, this);
+ return jsonParseGet.call(this, key);
},
set: function (val: string[]) {
- return jsonParseSet(key, this, val);
+ return jsonParseSet.call(this, key, val);
},
allowNull: false,
defaultValue: '[]'