aboutsummaryrefslogtreecommitdiff
path: root/src/listeners
diff options
context:
space:
mode:
authorIRONM00N <64110067+IRONM00N@users.noreply.github.com>2021-07-26 18:45:31 -0400
committerIRONM00N <64110067+IRONM00N@users.noreply.github.com>2021-07-26 18:45:31 -0400
commitcca0b7a03bcd61af12b7f9bff51276f6c70beeb3 (patch)
tree2b2adebc166ac033520e5b582773e63fbdc5ddb9 /src/listeners
parent13ba1ad552047eb9386e91d542a975c4bef58b08 (diff)
downloadtanzanite-cca0b7a03bcd61af12b7f9bff51276f6c70beeb3.tar.gz
tanzanite-cca0b7a03bcd61af12b7f9bff51276f6c70beeb3.tar.bz2
tanzanite-cca0b7a03bcd61af12b7f9bff51276f6c70beeb3.zip
refactor: this.client.util -> util
Diffstat (limited to 'src/listeners')
-rw-r--r--src/listeners/client/interactionCreate.ts2
-rw-r--r--src/listeners/commands/commandBlocked.ts18
-rw-r--r--src/listeners/commands/commandError.ts10
-rw-r--r--src/listeners/commands/commandMissingPermissions.ts12
-rw-r--r--src/listeners/commands/slashBlocked.ts18
-rw-r--r--src/listeners/commands/slashCommandError.ts10
-rw-r--r--src/listeners/commands/slashMissingPermissions.ts12
-rw-r--r--src/listeners/message/automodCreate.ts2
-rw-r--r--src/listeners/message/automodUpdate.ts2
-rw-r--r--src/listeners/other/promiseRejection.ts4
-rw-r--r--src/listeners/other/uncaughtException.ts4
11 files changed, 47 insertions, 47 deletions
diff --git a/src/listeners/client/interactionCreate.ts b/src/listeners/client/interactionCreate.ts
index 0503f2e..77912d6 100644
--- a/src/listeners/client/interactionCreate.ts
+++ b/src/listeners/client/interactionCreate.ts
@@ -27,7 +27,7 @@ export default class InteractionCreateListener extends BushListener {
return await interaction.reply({
content: `You selected ${
Array.isArray(interaction.values)
- ? this.client.util.oxford(this.client.util.surroundArray(interaction.values, '`'), 'and', '')
+ ? util.oxford(util.surroundArray(interaction.values, '`'), 'and', '')
: `\`${interaction.values}\``
}.`,
ephemeral: true
diff --git a/src/listeners/commands/commandBlocked.ts b/src/listeners/commands/commandBlocked.ts
index e75610b..e495f52 100644
--- a/src/listeners/commands/commandBlocked.ts
+++ b/src/listeners/commands/commandBlocked.ts
@@ -19,22 +19,22 @@ export default class CommandBlockedListener extends BushListener {
switch (reason) {
case reasons.OWNER: {
return await message.util.reply({
- content: `${this.client.util.emojis.error} Only my developers can run the \`${message.util.parsed.command}\` command.`
+ content: `${util.emojis.error} Only my developers can run the \`${message.util.parsed.command}\` command.`
});
}
case reasons.SUPER_USER: {
return await message.util.reply({
- content: `${this.client.util.emojis.error} You must be a superuser to run the \`${message.util.parsed.command}\` command.`
+ content: `${util.emojis.error} You must be a superuser to run the \`${message.util.parsed.command}\` command.`
});
}
case reasons.DISABLED_GLOBAL: {
return await message.util.reply({
- content: `${this.client.util.emojis.error} My developers disabled the \`${message.util.parsed.command}\` command.`
+ content: `${util.emojis.error} My developers disabled the \`${message.util.parsed.command}\` command.`
});
}
case reasons.DISABLED_GUILD: {
return await message.util.reply({
- content: `${this.client.util.emojis.error} The \`${command.aliases[0]}\` command is currently disabled in \`${message.guild.name}\`.`
+ content: `${util.emojis.error} The \`${command.aliases[0]}\` command is currently disabled in \`${message.guild.name}\`.`
});
}
case reasons.CHANNEL_GLOBAL_BLACKLIST:
@@ -50,9 +50,9 @@ export default class CommandBlockedListener extends BushListener {
channels.forEach((c) => {
names.push(`<#${c}>`);
});
- const pretty = this.client.util.oxford(names, 'and', undefined);
+ const pretty = util.oxford(names, 'and', undefined);
return await message.util.reply({
- content: `${this.client.util.emojis.error} \`${command}\` can only be run in ${pretty}.`
+ content: `${util.emojis.error} \`${command}\` can only be run in ${pretty}.`
});
}
case reasons.RESTRICTED_GUILD: {
@@ -61,14 +61,14 @@ export default class CommandBlockedListener extends BushListener {
guilds.forEach((g) => {
names.push(`\`${this.client.guilds.cache.get(g).name}\``);
});
- const pretty = this.client.util.oxford(names, 'and', undefined);
+ const pretty = util.oxford(names, 'and', undefined);
return await message.util.reply({
- content: `${this.client.util.emojis.error} \`${command}\` can only be run in ${pretty}.`
+ content: `${util.emojis.error} \`${command}\` can only be run in ${pretty}.`
});
}
default: {
return await message.util.reply({
- content: `${this.client.util.emojis.error} Command blocked with reason \`${reason}\``
+ content: `${util.emojis.error} Command blocked with reason \`${reason}\``
});
}
}
diff --git a/src/listeners/commands/commandError.ts b/src/listeners/commands/commandError.ts
index 6de764c..c34f52a 100644
--- a/src/listeners/commands/commandError.ts
+++ b/src/listeners/commands/commandError.ts
@@ -20,8 +20,8 @@ export default class CommandErrorListener extends BushListener {
**Channel:** ${message.channel} (${message.channel?.id})
**Message:** [link](${message.url})`
)
- .addField('Error', await this.client.util.codeblock(`${error?.stack || error}`, 1024, 'js'))
- .setColor(this.client.util.colors.error)
+ .addField('Error', await util.codeblock(`${error?.stack || error}`, 1024, 'js'))
+ .setColor(util.colors.error)
.setTimestamp();
await this.client.logger.channelError({ embeds: [errorEmbed] });
@@ -29,7 +29,7 @@ export default class CommandErrorListener extends BushListener {
if (!this.client.config.owners.includes(message.author.id)) {
const errorUserEmbed: MessageEmbed = new MessageEmbed()
.setTitle('A Command Error Occurred')
- .setColor(this.client.util.colors.error)
+ .setColor(util.colors.error)
.setTimestamp();
if (!command)
errorUserEmbed.setDescription(`Oh no! An error occurred. Please give the developers code \`${errorNo}\`.`);
@@ -44,9 +44,9 @@ export default class CommandErrorListener extends BushListener {
} else {
const errorDevEmbed = new MessageEmbed()
.setTitle('A Command Error Occurred')
- .setColor(this.client.util.colors.error)
+ .setColor(util.colors.error)
.setTimestamp()
- .setDescription(await this.client.util.codeblock(`${error?.stack || error}`, 2048, 'js'));
+ .setDescription(await util.codeblock(`${error?.stack || error}`, 2048, 'js'));
(await message.util?.send({ embeds: [errorDevEmbed] }).catch((e) => {
const channel = message.channel.type === 'DM' ? message.channel.recipient.tag : message.channel.name;
this.client.console.warn('CommandError', `Failed to send owner error stack in <<${channel}>>.` + e?.stack || e);
diff --git a/src/listeners/commands/commandMissingPermissions.ts b/src/listeners/commands/commandMissingPermissions.ts
index e06f8f8..1df54ab 100644
--- a/src/listeners/commands/commandMissingPermissions.ts
+++ b/src/listeners/commands/commandMissingPermissions.ts
@@ -19,8 +19,8 @@ export default class CommandMissingPermissionsListener extends BushListener {
}
});
- const discordFormat = this.client.util.oxford(this.client.util.surroundArray(niceMissing, '**'), 'and', '');
- const consoleFormat = this.client.util.oxford(this.client.util.surroundArray(niceMissing, '<<', '>>'), 'and', '');
+ const discordFormat = util.oxford(util.surroundArray(niceMissing, '**'), 'and', '');
+ const consoleFormat = util.oxford(util.surroundArray(niceMissing, '<<', '>>'), 'and', '');
this.client.console.info(
'CommandMissingPermissions',
`<<${message.author.tag}>> tried to run <<${
@@ -30,15 +30,15 @@ export default class CommandMissingPermissionsListener extends BushListener {
if (type == 'client') {
await message.util
.reply(
- `${this.client.util.emojis.error} I am missing the ${discordFormat} permission${
- missing.length ? 's' : ''
- } required for the \`${command?.id}\` command.`
+ `${util.emojis.error} I am missing the ${discordFormat} permission${missing.length ? 's' : ''} required for the \`${
+ command?.id
+ }\` command.`
)
.catch(() => {});
} else if (type == 'user') {
await message.util
.reply(
- `${this.client.util.emojis.error} You are missing the ${discordFormat} permission${
+ `${util.emojis.error} You are missing the ${discordFormat} permission${
missing.length ? 's' : ''
} required for the **${command?.id}** command.`
)
diff --git a/src/listeners/commands/slashBlocked.ts b/src/listeners/commands/slashBlocked.ts
index e59235e..7c26fb5 100644
--- a/src/listeners/commands/slashBlocked.ts
+++ b/src/listeners/commands/slashBlocked.ts
@@ -21,22 +21,22 @@ export default class SlashBlockedListener extends BushListener {
switch (reason) {
case reasons.OWNER: {
return await message.util.reply({
- content: `${this.client.util.emojis.error} Only my developers can run the \`${message.util.parsed.command}\` command.`
+ content: `${util.emojis.error} Only my developers can run the \`${message.util.parsed.command}\` command.`
});
}
case reasons.SUPER_USER: {
return await message.util.reply({
- content: `${this.client.util.emojis.error} You must be a superuser to run the \`${message.util.parsed.command}\` command.`
+ content: `${util.emojis.error} You must be a superuser to run the \`${message.util.parsed.command}\` command.`
});
}
case reasons.DISABLED_GLOBAL: {
return await message.util.reply({
- content: `${this.client.util.emojis.error} My developers disabled the \`${message.util.parsed.command}\` command.`
+ content: `${util.emojis.error} My developers disabled the \`${message.util.parsed.command}\` command.`
});
}
case reasons.DISABLED_GUILD: {
return await message.util.reply({
- content: `${this.client.util.emojis.error} The \`${command.aliases[0]}\` command is currently disabled in \`${message.guild.name}\`.`
+ content: `${util.emojis.error} The \`${command.aliases[0]}\` command is currently disabled in \`${message.guild.name}\`.`
});
}
case reasons.CHANNEL_GLOBAL_BLACKLIST:
@@ -52,9 +52,9 @@ export default class SlashBlockedListener extends BushListener {
channels.forEach((c) => {
names.push(`<#${c}>`);
});
- const pretty = this.client.util.oxford(names, 'and', undefined);
+ const pretty = util.oxford(names, 'and', undefined);
return await message.util.reply({
- content: `${this.client.util.emojis.error} \`${command}\` can only be run in ${pretty}.`
+ content: `${util.emojis.error} \`${command}\` can only be run in ${pretty}.`
});
}
case reasons.RESTRICTED_GUILD: {
@@ -63,14 +63,14 @@ export default class SlashBlockedListener extends BushListener {
guilds.forEach((g) => {
names.push(`\`${this.client.guilds.cache.get(g).name}\``);
});
- const pretty = this.client.util.oxford(names, 'and', undefined);
+ const pretty = util.oxford(names, 'and', undefined);
return await message.util.reply({
- content: `${this.client.util.emojis.error} \`${command}\` can only be run in ${pretty}.`
+ content: `${util.emojis.error} \`${command}\` can only be run in ${pretty}.`
});
}
default: {
return await message.util.reply({
- content: `${this.client.util.emojis.error} Command blocked with reason \`${reason}\``
+ content: `${util.emojis.error} Command blocked with reason \`${reason}\``
});
}
}
diff --git a/src/listeners/commands/slashCommandError.ts b/src/listeners/commands/slashCommandError.ts
index 03ba899..c66076d 100644
--- a/src/listeners/commands/slashCommandError.ts
+++ b/src/listeners/commands/slashCommandError.ts
@@ -20,8 +20,8 @@ export default class SlashCommandErrorListener extends BushListener {
**Channel:** ${message.channel || message.interaction.user?.tag} ${message.channel ? `(${message.channel?.id})` : ''}
**Message:** [link](https://discord.com/${message.guild?.id}/${message.channel?.id}/${message.id})`
)
- .addField('Error', await this.client.util.codeblock(`${error?.stack || error}`, 1024, 'js'))
- .setColor(this.client.util.colors.error)
+ .addField('Error', await util.codeblock(`${error?.stack || error}`, 1024, 'js'))
+ .setColor(util.colors.error)
.setTimestamp();
await this.client.logger.channelError({ embeds: [errorEmbed] });
@@ -30,7 +30,7 @@ export default class SlashCommandErrorListener extends BushListener {
if (!this.client.config.owners.includes(message.author.id)) {
const errorUserEmbed: MessageEmbed = new MessageEmbed()
.setTitle('A Slash Command Error Occurred')
- .setColor(this.client.util.colors.error)
+ .setColor(util.colors.error)
.setTimestamp();
if (!command)
errorUserEmbed.setDescription(`Oh no! An error occurred. Please give the developers code \`${errorNo}\`.`);
@@ -44,9 +44,9 @@ export default class SlashCommandErrorListener extends BushListener {
} else {
const errorDevEmbed = new MessageEmbed()
.setTitle('A Slash Command Error Occurred')
- .setColor(this.client.util.colors.error)
+ .setColor(util.colors.error)
.setTimestamp()
- .setDescription(await this.client.util.codeblock(`${error?.stack || error}`, 2048, 'js'));
+ .setDescription(await util.codeblock(`${error?.stack || error}`, 2048, 'js'));
(await message.util?.send({ embeds: [errorDevEmbed] }).catch((e) => {
this.client.console.warn('SlashError', `Failed to send owner error stack in <<${channel}>>.` + e?.stack || e);
})) ?? this.client.console.error('SlashError', `Failed to send user error embed.` + error?.stack || error, false);
diff --git a/src/listeners/commands/slashMissingPermissions.ts b/src/listeners/commands/slashMissingPermissions.ts
index a41dd8f..34786e1 100644
--- a/src/listeners/commands/slashMissingPermissions.ts
+++ b/src/listeners/commands/slashMissingPermissions.ts
@@ -19,8 +19,8 @@ export default class SlashMissingPermissionsListener extends BushListener {
}
});
- const discordFormat = this.client.util.oxford(this.client.util.surroundArray(niceMissing, '`'), 'and', '');
- const consoleFormat = this.client.util.oxford(this.client.util.surroundArray(niceMissing, '<<', '>>'), 'and', '');
+ const discordFormat = util.oxford(util.surroundArray(niceMissing, '`'), 'and', '');
+ const consoleFormat = util.oxford(util.surroundArray(niceMissing, '<<', '>>'), 'and', '');
this.client.console.info(
'CommandMissingPermissions',
`<<${message.author.tag}>> tried to run <<${
@@ -31,15 +31,15 @@ export default class SlashMissingPermissionsListener extends BushListener {
if (type == 'client') {
await message.util
.reply(
- `${this.client.util.emojis.error} I am missing the ${discordFormat} permission${
- missing.length ? 's' : ''
- } required for the \`${command?.id}\` command.`
+ `${util.emojis.error} I am missing the ${discordFormat} permission${missing.length ? 's' : ''} required for the \`${
+ command?.id
+ }\` command.`
)
.catch(() => {});
} else if (type == 'user') {
await message.util
.reply(
- `${this.client.util.emojis.error} You are missing the ${discordFormat} permission${
+ `${util.emojis.error} You are missing the ${discordFormat} permission${
missing.length ? 's' : ''
} required for the \`${command?.id}\` command.`
)
diff --git a/src/listeners/message/automodCreate.ts b/src/listeners/message/automodCreate.ts
index 9b7d0ec..b8057c5 100644
--- a/src/listeners/message/automodCreate.ts
+++ b/src/listeners/message/automodCreate.ts
@@ -11,6 +11,6 @@ export default class AutomodMessageCreateListener extends BushListener {
}
async exec(...[message]: ClientEvents['messageCreate']): Promise<void> {
- return await this.client.util.automod(message as BushMessage);
+ return await util.automod(message as BushMessage);
}
}
diff --git a/src/listeners/message/automodUpdate.ts b/src/listeners/message/automodUpdate.ts
index 37e00bf..9d17ef0 100644
--- a/src/listeners/message/automodUpdate.ts
+++ b/src/listeners/message/automodUpdate.ts
@@ -12,6 +12,6 @@ export default class AutomodMessageUpdateListener extends BushListener {
async exec(...[message]: ClientEvents['messageUpdate']): Promise<void> {
const fullMessage = message.partial ? await message.fetch() : (message as Message);
- return await this.client.util.automod(fullMessage as BushMessage);
+ return await util.automod(fullMessage as BushMessage);
}
}
diff --git a/src/listeners/other/promiseRejection.ts b/src/listeners/other/promiseRejection.ts
index 460d849..da6480c 100644
--- a/src/listeners/other/promiseRejection.ts
+++ b/src/listeners/other/promiseRejection.ts
@@ -14,8 +14,8 @@ export default class PromiseRejectionListener extends BushListener {
embeds: [
{
title: 'Unhandled promise rejection',
- fields: [{ name: 'error', value: await this.client.util.codeblock(`${error?.stack || error}`, 1024, 'js') }],
- color: this.client.util.colors.error
+ fields: [{ name: 'error', value: await util.codeblock(`${error?.stack || error}`, 1024, 'js') }],
+ color: util.colors.error
}
]
});
diff --git a/src/listeners/other/uncaughtException.ts b/src/listeners/other/uncaughtException.ts
index 91d0a56..1bb57c1 100644
--- a/src/listeners/other/uncaughtException.ts
+++ b/src/listeners/other/uncaughtException.ts
@@ -14,8 +14,8 @@ export default class UncaughtExceptionListener extends BushListener {
embeds: [
{
title: 'An uncaught exception occurred',
- fields: [{ name: 'error', value: await this.client.util.codeblock(`${error?.stack || error}`, 1024, 'js') }],
- color: this.client.util.colors.error
+ fields: [{ name: 'error', value: await util.codeblock(`${error?.stack || error}`, 1024, 'js') }],
+ color: util.colors.error
}
]
});