aboutsummaryrefslogtreecommitdiff
path: root/src/lib/extensions
diff options
context:
space:
mode:
authorIRONM00N <64110067+IRONM00N@users.noreply.github.com>2021-07-26 18:47:13 -0400
committerIRONM00N <64110067+IRONM00N@users.noreply.github.com>2021-07-26 18:47:13 -0400
commit80d5b5b11ae261945dc725a0a80115922003afcf (patch)
tree16c9f251b4d53456b4b5340c0203d35fd5870859 /src/lib/extensions
parentcca0b7a03bcd61af12b7f9bff51276f6c70beeb3 (diff)
downloadtanzanite-80d5b5b11ae261945dc725a0a80115922003afcf.tar.gz
tanzanite-80d5b5b11ae261945dc725a0a80115922003afcf.tar.bz2
tanzanite-80d5b5b11ae261945dc725a0a80115922003afcf.zip
refactor: this.client -> client
Diffstat (limited to 'src/lib/extensions')
-rw-r--r--src/lib/extensions/discord-akairo/BushClientUtil.ts44
-rw-r--r--src/lib/extensions/discord-akairo/BushCommandHandler.ts4
-rw-r--r--src/lib/extensions/discord.js/BushGuild.ts10
-rw-r--r--src/lib/extensions/discord.js/BushGuildMember.ts20
-rw-r--r--src/lib/extensions/discord.js/BushMessage.ts2
-rw-r--r--src/lib/extensions/discord.js/BushUser.ts4
6 files changed, 42 insertions, 42 deletions
diff --git a/src/lib/extensions/discord-akairo/BushClientUtil.ts b/src/lib/extensions/discord-akairo/BushClientUtil.ts
index b35725d..20fb468 100644
--- a/src/lib/extensions/discord-akairo/BushClientUtil.ts
+++ b/src/lib/extensions/discord-akairo/BushClientUtil.ts
@@ -135,7 +135,7 @@ export class BushClientUtil extends ClientUtil {
* @returns The list of users mapped
*/
public async mapIDs(ids: Snowflake[]): Promise<User[]> {
- return await Promise.all(ids.map((id) => this.client.users.fetch(id)));
+ return await Promise.all(ids.map((id) => client.users.fetch(id)));
}
/**
@@ -170,7 +170,7 @@ export class BushClientUtil extends ClientUtil {
const res: hastebinRes = await got.post(`${url}/documents`, { body: content }).json();
return `${url}/${res.key}`;
} catch {
- this.client.console.error('Haste', `Unable to upload haste to ${url}`);
+ client.console.error('Haste', `Unable to upload haste to ${url}`);
}
}
return 'Unable to post';
@@ -186,7 +186,7 @@ export class BushClientUtil extends ClientUtil {
const idMatch = text.match(idReg);
if (idMatch) {
try {
- return await this.client.users.fetch(text as Snowflake);
+ return await client.users.fetch(text as Snowflake);
} catch {
// pass
}
@@ -195,12 +195,12 @@ export class BushClientUtil extends ClientUtil {
const mentionMatch = text.match(mentionReg);
if (mentionMatch) {
try {
- return await this.client.users.fetch(mentionMatch.groups.id as Snowflake);
+ return await client.users.fetch(mentionMatch.groups.id as Snowflake);
} catch {
// pass
}
}
- const user = this.client.users.cache.find((u) => u.username === text);
+ const user = client.users.cache.find((u) => u.username === text);
if (user) return user;
return null;
}
@@ -322,7 +322,7 @@ export class BushClientUtil extends ClientUtil {
interaction.customId.startsWith('paginate_') && interaction.message == msg;
const collector = msg.createMessageComponentCollector({ filter, time: 300000 });
collector.on('collect', async (interaction: MessageComponentInteraction) => {
- if (interaction.user.id == message.author.id || this.client.config.owners.includes(interaction.user.id)) {
+ if (interaction.user.id == message.author.id || client.config.owners.includes(interaction.user.id)) {
switch (interaction.customId) {
case 'paginate_beginning': {
curPage = 0;
@@ -411,7 +411,7 @@ export class BushClientUtil extends ClientUtil {
const filter = (interaction: ButtonInteraction) => interaction.customId == 'paginate__stop' && interaction.message == msg;
const collector = msg.createMessageComponentCollector({ filter, time: 300000 });
collector.on('collect', async (interaction: MessageComponentInteraction) => {
- if (interaction.user.id == message.author.id || this.client.config.owners.includes(interaction.user.id)) {
+ if (interaction.user.id == message.author.id || client.config.owners.includes(interaction.user.id)) {
await interaction.deferUpdate().catch(() => undefined);
if (msg.deletable && !msg.deleted) {
await msg.delete();
@@ -521,7 +521,7 @@ export class BushClientUtil extends ClientUtil {
/** Gets the channel configs as a TextChannel */
public async getConfigChannel(channel: 'log' | 'error' | 'dm'): Promise<TextChannel> {
- return (await this.client.channels.fetch(this.client.config.channels[channel])) as TextChannel;
+ return (await client.channels.fetch(client.config.channels[channel])) as TextChannel;
}
/**
@@ -551,12 +551,12 @@ export class BushClientUtil extends ClientUtil {
key: keyof typeof BushCache['global'],
value: any
): Promise<Global | void> {
- const row = await Global.findByPk(this.client.config.environment);
+ const row = await Global.findByPk(client.config.environment);
const oldValue: any[] = row[key];
const newValue = this.addOrRemoveFromArray(action, oldValue, value);
row[key] = newValue;
- this.client.cache.global[key] = newValue;
- return await row.save().catch((e) => this.client.logger.error('insertOrRemoveFromGlobal', e?.stack || e));
+ client.cache.global[key] = newValue;
+ return await row.save().catch((e) => client.logger.error('insertOrRemoveFromGlobal', e?.stack || e));
}
public addOrRemoveFromArray(action: 'add' | 'remove', array: any[], value: any): any[] {
@@ -657,9 +657,9 @@ export class BushClientUtil extends ClientUtil {
},
getCaseNumber = false
): Promise<{ log: ModLog; caseNum: number }> {
- const user = this.client.users.resolveId(options.user);
- const moderator = this.client.users.resolveId(options.moderator);
- const guild = this.client.guilds.resolveId(options.guild);
+ const user = client.users.resolveId(options.user);
+ const moderator = client.users.resolveId(options.moderator);
+ const guild = client.guilds.resolveId(options.guild);
const duration = options.duration || null;
// If guild does not exist create it so the modlog can reference a guild.
@@ -681,7 +681,7 @@ export class BushClientUtil extends ClientUtil {
guild
});
const saveResult: ModLog = await modLogEntry.save().catch((e) => {
- this.client.console.error('createModLogEntry', e?.stack || e);
+ client.console.error('createModLogEntry', e?.stack || e);
return null;
});
@@ -700,15 +700,15 @@ export class BushClientUtil extends ClientUtil {
extraInfo?: Snowflake;
}): Promise<ActivePunishment> {
const expires = options.duration ? new Date(new Date().getTime() + options.duration) : null;
- const user = this.client.users.resolveId(options.user);
- const guild = this.client.guilds.resolveId(options.guild);
+ const user = client.users.resolveId(options.user);
+ const guild = client.guilds.resolveId(options.guild);
const type = this.findTypeEnum(options.type);
const entry = options.extraInfo
? ActivePunishment.build({ user, type, guild, expires, modlog: options.modlog, extraInfo: options.extraInfo })
: ActivePunishment.build({ user, type, guild, expires, modlog: options.modlog });
return await entry.save().catch((e) => {
- this.client.console.error('createPunishmentEntry', e?.stack || e);
+ client.console.error('createPunishmentEntry', e?.stack || e);
return null;
});
}
@@ -718,8 +718,8 @@ export class BushClientUtil extends ClientUtil {
user: BushGuildMemberResolvable;
guild: BushGuildResolvable;
}): Promise<boolean> {
- const user = this.client.users.resolveId(options.user);
- const guild = this.client.guilds.resolveId(options.guild);
+ const user = client.users.resolveId(options.user);
+ const guild = client.guilds.resolveId(options.guild);
const type = this.findTypeEnum(options.type);
let success = true;
@@ -728,13 +728,13 @@ export class BushClientUtil extends ClientUtil {
// finding all cases of a certain type incase there were duplicates or something
where: { user, guild, type }
}).catch((e) => {
- this.client.console.error('removePunishmentEntry', e?.stack || e);
+ client.console.error('removePunishmentEntry', e?.stack || e);
success = false;
});
if (entries) {
entries.forEach(async (entry) => {
await entry.destroy().catch((e) => {
- this.client.console.error('removePunishmentEntry', e?.stack || e);
+ client.console.error('removePunishmentEntry', e?.stack || e);
});
success = false;
});
diff --git a/src/lib/extensions/discord-akairo/BushCommandHandler.ts b/src/lib/extensions/discord-akairo/BushCommandHandler.ts
index ae8f95b..f16554c 100644
--- a/src/lib/extensions/discord-akairo/BushCommandHandler.ts
+++ b/src/lib/extensions/discord-akairo/BushCommandHandler.ts
@@ -37,7 +37,7 @@ export class BushCommandHandler extends CommandHandler {
public async runPostTypeInhibitors(message: BushMessage, command: BushCommand, slash = false): Promise<boolean> {
if (command.ownerOnly) {
- const isOwner = this.client.isOwner(message.author);
+ const isOwner = client.isOwner(message.author);
if (!isOwner) {
this.emit(
slash ? commandHandlerEvents.SLASH_BLOCKED : commandHandlerEvents.COMMAND_BLOCKED,
@@ -50,7 +50,7 @@ export class BushCommandHandler extends CommandHandler {
}
if (command.superUserOnly) {
- const isSuperUser = this.client.isSuperUser(message.author);
+ const isSuperUser = client.isSuperUser(message.author);
if (!isSuperUser) {
this.emit(
slash ? commandHandlerEvents.SLASH_BLOCKED : commandHandlerEvents.COMMAND_BLOCKED,
diff --git a/src/lib/extensions/discord.js/BushGuild.ts b/src/lib/extensions/discord.js/BushGuild.ts
index 0e4891e..9d618ec 100644
--- a/src/lib/extensions/discord.js/BushGuild.ts
+++ b/src/lib/extensions/discord.js/BushGuild.ts
@@ -13,7 +13,7 @@ export class BushGuild extends Guild {
public async getSetting<K extends keyof GuildModel>(setting: K): Promise<GuildModel[K]> {
return (
- this.client.cache.guilds.get(this.id)?.[setting] ??
+ client.cache.guilds.get(this.id)?.[setting] ??
((await GuildDB.findByPk(this.id)) ?? GuildDB.build({ id: this.id }))[setting]
);
}
@@ -21,7 +21,7 @@ export class BushGuild extends Guild {
public async setSetting<K extends keyof GuildModel>(setting: K, value: GuildDB[K]): Promise<GuildDB> {
const row = (await GuildDB.findByPk(this.id)) ?? GuildDB.build({ id: this.id });
row[setting] = value;
- this.client.cache.guilds.set(this.id, row.toJSON() as GuildDB);
+ client.cache.guilds.set(this.id, row.toJSON() as GuildDB);
return await row.save();
}
@@ -37,8 +37,8 @@ export class BushGuild extends Guild {
| 'error creating modlog entry'
| 'error removing ban entry'
> {
- const user = this.client.users.resolveId(options.user);
- const moderator = this.client.users.cache.get(this.client.users.resolveId(options.moderator));
+ const user = client.users.resolveId(options.user);
+ const moderator = client.users.cache.get(client.users.resolveId(options.moderator));
const bans = await this.bans.fetch();
@@ -76,7 +76,7 @@ export class BushGuild extends Guild {
.catch(() => null);
if (!removePunishmentEntrySuccess) return 'error removing ban entry';
- const userObject = this.client.users.cache.get(user);
+ const userObject = client.users.cache.get(user);
userObject?.send(`You have been unbanned from **${this}** for **${options.reason || 'No reason provided'}**.`);
diff --git a/src/lib/extensions/discord.js/BushGuildMember.ts b/src/lib/extensions/discord.js/BushGuildMember.ts
index c04c8f0..70feb90 100644
--- a/src/lib/extensions/discord.js/BushGuildMember.ts
+++ b/src/lib/extensions/discord.js/BushGuildMember.ts
@@ -80,7 +80,7 @@ export class BushGuildMember extends GuildMember {
}
public async warn(options: BushPunishmentOptions): Promise<{ result: WarnResponse; caseNum: number }> {
- const moderator = this.client.users.cache.get(this.client.users.resolveId(options.moderator || this.client.user));
+ const moderator = client.users.cache.get(client.users.resolveId(options.moderator || client.user));
// add modlog entry
const result = await util
.createModLogEntry(
@@ -94,7 +94,7 @@ export class BushGuildMember extends GuildMember {
true
)
.catch((e) => {
- this.client.console.error('warn', e, true, 1);
+ client.console.error('warn', e, true, 1);
return { log: null, caseNum: null };
});
if (!result || !result.log) return { result: 'error creating modlog entry', caseNum: null };
@@ -116,7 +116,7 @@ export class BushGuildMember extends GuildMember {
const ifShouldAddRole = this.checkIfShouldAddRole(options.role);
if (ifShouldAddRole !== true) return ifShouldAddRole;
- const moderator = this.client.users.cache.get(this.client.users.resolveId(options.moderator || this.client.user));
+ const moderator = client.users.cache.get(client.users.resolveId(options.moderator || client.user));
if (options.addToModlog) {
const { log: modlog } = await util
@@ -153,7 +153,7 @@ export class BushGuildMember extends GuildMember {
const ifShouldAddRole = this.checkIfShouldAddRole(options.role);
if (ifShouldAddRole !== true) return ifShouldAddRole;
- const moderator = this.client.users.cache.get(this.client.users.resolveId(options.moderator || this.client.user));
+ const moderator = client.users.cache.get(client.users.resolveId(options.moderator || client.user));
if (options.addToModlog) {
const { log: modlog } = await util
@@ -203,7 +203,7 @@ export class BushGuildMember extends GuildMember {
if (!muteRole) return 'invalid mute role';
if (muteRole.position >= this.guild.me.roles.highest.position || muteRole.managed) return 'mute role not manageable';
- const moderator = this.client.users.cache.get(this.client.users.resolveId(options.moderator || this.client.user));
+ const moderator = client.users.cache.get(client.users.resolveId(options.moderator || client.user));
// add role
const muteSuccess = await this.roles
@@ -258,7 +258,7 @@ export class BushGuildMember extends GuildMember {
if (!muteRole) return 'invalid mute role';
if (muteRole.position >= this.guild.me.roles.highest.position || muteRole.managed) return 'mute role not manageable';
- const moderator = this.client.users.cache.get(this.client.users.resolveId(options.moderator || this.client.user));
+ const moderator = client.users.cache.get(client.users.resolveId(options.moderator || client.user));
//remove role
const muteSuccess = await this.roles
@@ -302,7 +302,7 @@ export class BushGuildMember extends GuildMember {
// checks
if (!this.guild.me.permissions.has('KICK_MEMBERS') || !this.kickable) return 'missing permissions';
- const moderator = this.client.users.cache.get(this.client.users.resolveId(options.moderator || this.client.user));
+ const moderator = client.users.cache.get(client.users.resolveId(options.moderator || client.user));
// dm user
const ending = await this.guild.getSetting('punishmentEnding');
@@ -335,7 +335,7 @@ export class BushGuildMember extends GuildMember {
// checks
if (!this.guild.me.permissions.has('BAN_MEMBERS') || !this.bannable) return 'missing permissions';
- const moderator = this.client.users.cache.get(this.client.users.resolveId(options.moderator || this.client.user));
+ const moderator = client.users.cache.get(client.users.resolveId(options.moderator || client.user));
// dm user
const ending = await this.guild.getSetting('punishmentEnding');
@@ -382,10 +382,10 @@ export class BushGuildMember extends GuildMember {
}
public get isOwner(): boolean {
- return this.client.isOwner(this);
+ return client.isOwner(this);
}
public get isSuperUser(): boolean {
- return this.client.isSuperUser(this);
+ return client.isSuperUser(this);
}
}
diff --git a/src/lib/extensions/discord.js/BushMessage.ts b/src/lib/extensions/discord.js/BushMessage.ts
index d4b47c6..68f3de0 100644
--- a/src/lib/extensions/discord.js/BushMessage.ts
+++ b/src/lib/extensions/discord.js/BushMessage.ts
@@ -21,6 +21,6 @@ export class BushMessage extends Message {
channel: BushTextChannel | BushDMChannel | BushNewsChannel | BushThreadChannel
) {
super(client, data, channel);
- // this.util = new BushCommandUtil(this.client.commandHandler, this);
+ // this.util = new BushCommandUtil(client.commandHandler, this);
}
}
diff --git a/src/lib/extensions/discord.js/BushUser.ts b/src/lib/extensions/discord.js/BushUser.ts
index 53a6be3..54a67b5 100644
--- a/src/lib/extensions/discord.js/BushUser.ts
+++ b/src/lib/extensions/discord.js/BushUser.ts
@@ -10,10 +10,10 @@ export class BushUser extends User {
}
public isOwner(): boolean {
- return this.client.isOwner(this);
+ return client.isOwner(this);
}
public isSuperUser(): boolean {
- return this.client.isSuperUser(this);
+ return client.isSuperUser(this);
}
}