aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/commands/dev/reload.ts14
-rw-r--r--src/commands/info/pronouns.ts25
-rw-r--r--src/commands/moulberry-bush/level.ts5
-rw-r--r--src/lib/extensions/Util.ts87
-rw-r--r--src/listeners/client/syncSlashCommands.ts5
5 files changed, 25 insertions, 111 deletions
diff --git a/src/commands/dev/reload.ts b/src/commands/dev/reload.ts
index 36c6fd7..0cf32ce 100644
--- a/src/commands/dev/reload.ts
+++ b/src/commands/dev/reload.ts
@@ -42,9 +42,7 @@ export default class ReloadCommand extends BushCommand {
this.client.commandHandler.reloadAll();
this.client.listenerHandler.reloadAll();
this.client.inhibitorHandler.reloadAll();
- return `🔁 Successfully reloaded! (${
- new Date().getTime() - s.getTime()
- }ms)`;
+ return `🔁 Successfully reloaded! (${new Date().getTime() - s.getTime()}ms)`;
} catch (e) {
return stripIndent`
An error occured while reloading:
@@ -53,17 +51,11 @@ export default class ReloadCommand extends BushCommand {
}
}
- public async exec(
- message: Message,
- { fast }: { fast: boolean }
- ): Promise<void> {
+ public async exec(message: Message, { fast }: { fast: boolean }): Promise<void> {
await message.util.send(await this.getResponse(fast));
}
- public async execSlash(
- message: CommandInteraction,
- { fast }: { fast: SlashCommandOption<boolean> }
- ): Promise<void> {
+ public async execSlash(message: CommandInteraction, { fast }: { fast: SlashCommandOption<boolean> }): Promise<void> {
await message.reply(await this.getResponse(fast?.value));
}
}
diff --git a/src/commands/info/pronouns.ts b/src/commands/info/pronouns.ts
index 2c1d5f2..c53c542 100644
--- a/src/commands/info/pronouns.ts
+++ b/src/commands/info/pronouns.ts
@@ -59,17 +59,9 @@ export default class PronounsCommand extends BushCommand {
slashEmphemeral: true // I'll add dynamic checking to this later
});
}
- async sendResponse(
- message: Message | CommandInteraction,
- user: User,
- author: boolean
- ): Promise<void> {
+ async sendResponse(message: Message | CommandInteraction, user: User, author: boolean): Promise<void> {
try {
- const apiRes: { pronouns: pronounsType } = await got
- .get(
- `https://pronoundb.org/api/v1/lookup?platform=discord&id=${user.id}`
- )
- .json();
+ const apiRes: { pronouns: pronounsType } = await got.get(`https://pronoundb.org/api/v1/lookup?platform=discord&id=${user.id}`).json();
if (message instanceof Message) {
message.reply(
new MessageEmbed({
@@ -96,13 +88,9 @@ export default class PronounsCommand extends BushCommand {
} catch (e) {
if (e instanceof HTTPError && e.response.statusCode === 404) {
if (author) {
- await message.reply(
- 'You do not appear to have any pronouns set. Please go to https://pronoundb.org/ and set your pronouns.'
- );
+ await message.reply('You do not appear to have any pronouns set. Please go to https://pronoundb.org/ and set your pronouns.');
} else {
- await message.reply(
- `${user.tag} does not appear to have any pronouns set. Please tell them to go to https://pronoundb.org/ and set their pronouns.`
- );
+ await message.reply(`${user.tag} does not appear to have any pronouns set. Please tell them to go to https://pronoundb.org/ and set their pronouns.`);
}
} else throw e;
}
@@ -111,10 +99,7 @@ export default class PronounsCommand extends BushCommand {
const u = user || message.author;
await this.sendResponse(message, u, u.id === message.author.id);
}
- async execSlash(
- message: CommandInteraction,
- { user }: { user?: SlashCommandOption<void> }
- ): Promise<void> {
+ async execSlash(message: CommandInteraction, { user }: { user?: SlashCommandOption<void> }): Promise<void> {
const u = user?.user || message.user;
await this.sendResponse(message, u, u.id === message.user.id);
}
diff --git a/src/commands/moulberry-bush/level.ts b/src/commands/moulberry-bush/level.ts
index 554219d..05c1e0c 100644
--- a/src/commands/moulberry-bush/level.ts
+++ b/src/commands/moulberry-bush/level.ts
@@ -148,10 +148,7 @@ export default class LevelCommand extends BushCommand {
// );
await message.reply(await this.getResponse(user || message.author));
}
- async execSlash(
- message: CommandInteraction,
- { user }: { user?: CommandInteractionOption }
- ): Promise<void> {
+ async execSlash(message: CommandInteraction, { user }: { user?: CommandInteractionOption }): Promise<void> {
// await message.reply(
// new MessageAttachment(
// await this.getImage(user?.user || message.user),
diff --git a/src/lib/extensions/Util.ts b/src/lib/extensions/Util.ts
index 3e6882a..9106020 100644
--- a/src/lib/extensions/Util.ts
+++ b/src/lib/extensions/Util.ts
@@ -232,27 +232,11 @@ export class Util extends ClientUtil {
let fetchedGuild: Guild;
if (guild) fetchedGuild = this.client.guilds.cache.get(guild);
try {
- const registered =
- guild === undefined
- ? await this.client.application.commands.fetch()
- : await fetchedGuild.commands.fetch();
+ const registered = guild === undefined ? await this.client.application.commands.fetch() : await fetchedGuild.commands.fetch();
for (const [, registeredCommand] of registered) {
- if (
- !this.client.commandHandler.modules.find(
- (cmd) => cmd.id == registeredCommand.name
- )?.execSlash ||
- force
- ) {
- guild === undefined
- ? await this.client.application.commands.delete(
- registeredCommand.id
- )
- : await fetchedGuild.commands.delete(registeredCommand.id);
- this.client.logger.verbose(
- chalk`{red Deleted slash command ${registeredCommand.name}${
- guild !== undefined ? ` in guild ${fetchedGuild.name}` : ''
- }}`
- );
+ if (!this.client.commandHandler.modules.find((cmd) => cmd.id == registeredCommand.name)?.execSlash || force) {
+ guild === undefined ? await this.client.application.commands.delete(registeredCommand.id) : await fetchedGuild.commands.delete(registeredCommand.id);
+ this.client.logger.verbose(chalk`{red Deleted slash command ${registeredCommand.name}${guild !== undefined ? ` in guild ${fetchedGuild.name}` : ''}}`);
}
}
@@ -264,49 +248,25 @@ export class Util extends ClientUtil {
name: botCommand.id,
description: botCommand.description.content,
options: botCommand.options.slashCommandOptions
- };botCommand
+ };
+ botCommand;
if (found?.id && !force) {
if (slashdata.description !== found.description) {
- guild === undefined
- ? await this.client.application.commands.edit(
- found.id,
- slashdata
- )
- : fetchedGuild.commands.edit(found.id, slashdata);
- this.client.logger.verbose(
- chalk`{yellow Edited slash command ${botCommand.id}${
- guild !== undefined ? ` in guild ${fetchedGuild.name}` : ''
- }}`
- );
+ guild === undefined ? await this.client.application.commands.edit(found.id, slashdata) : fetchedGuild.commands.edit(found.id, slashdata);
+ this.client.logger.verbose(chalk`{yellow Edited slash command ${botCommand.id}${guild !== undefined ? ` in guild ${fetchedGuild.name}` : ''}}`);
}
} else {
- guild === undefined
- ? await this.client.application.commands.create(slashdata)
- : fetchedGuild.commands.create(slashdata);
- this.client.logger.verbose(
- chalk`{green Created slash command ${botCommand.id}${
- guild !== undefined ? ` in guild ${fetchedGuild.name}` : ''
- }}`
- );
+ guild === undefined ? await this.client.application.commands.create(slashdata) : fetchedGuild.commands.create(slashdata);
+ this.client.logger.verbose(chalk`{green Created slash command ${botCommand.id}${guild !== undefined ? ` in guild ${fetchedGuild.name}` : ''}}`);
}
}
}
- return this.client.logger.log(
- chalk.green(
- `Slash commands registered${
- guild !== undefined ? ` in guild ${fetchedGuild.name}` : ''
- }`
- )
- );
+ return this.client.logger.log(chalk.green(`Slash commands registered${guild !== undefined ? ` in guild ${fetchedGuild.name}` : ''}`));
} catch (e) {
console.log(chalk.red(e.stack));
- return this.client.logger.error(
- chalk`{red Slash commands not registered${
- guild !== undefined ? ` in guild ${fetchedGuild.name}` : ''
- }, see above error.}`
- );
+ return this.client.logger.error(chalk`{red Slash commands not registered${guild !== undefined ? ` in guild ${fetchedGuild.name}` : ''}, see above error.}`);
}
}
@@ -350,12 +310,7 @@ export class CanvasProgressBar {
private p: number;
private ctx: CanvasRenderingContext2D;
- constructor(
- ctx: CanvasRenderingContext2D,
- dimension: { x: number; y: number; width: number; height: number },
- color: string,
- percentage: number
- ) {
+ constructor(ctx: CanvasRenderingContext2D, dimension: { x: number; y: number; width: number; height: number }, color: string, percentage: number) {
({ x: this.x, y: this.y, width: this.w, height: this.h } = dimension);
this.color = color;
this.percentage = percentage;
@@ -388,21 +343,9 @@ export class CanvasProgressBar {
this.ctx.closePath();
} else {
this.ctx.beginPath();
- this.ctx.arc(
- this.h / 2 + this.x,
- this.h / 2 + this.y,
- this.h / 2,
- Math.PI / 2,
- (3 / 2) * Math.PI
- );
+ this.ctx.arc(this.h / 2 + this.x, this.h / 2 + this.y, this.h / 2, Math.PI / 2, (3 / 2) * Math.PI);
this.ctx.lineTo(this.p - this.h + this.x, 0 + this.y);
- this.ctx.arc(
- this.p - this.h / 2 + this.x,
- this.h / 2 + this.y,
- this.h / 2,
- (3 / 2) * Math.PI,
- Math.PI / 2
- );
+ this.ctx.arc(this.p - this.h / 2 + this.x, this.h / 2 + this.y, this.h / 2, (3 / 2) * Math.PI, Math.PI / 2);
this.ctx.lineTo(this.h / 2 + this.x, this.h + this.y);
this.ctx.closePath();
}
diff --git a/src/listeners/client/syncSlashCommands.ts b/src/listeners/client/syncSlashCommands.ts
index 7835136..69b91bc 100644
--- a/src/listeners/client/syncSlashCommands.ts
+++ b/src/listeners/client/syncSlashCommands.ts
@@ -10,10 +10,7 @@ export default class SyncSlashCommandsListener extends BushListener {
async exec(): Promise<void> {
if (this.client.config.dev && this.client.config.devGuild) {
// Use guild slash commands for instant registration in dev
- await this.client.util.syncSlashCommands(
- false,
- this.client.config.devGuild
- );
+ await this.client.util.syncSlashCommands(false, this.client.config.devGuild);
} else {
// Use global in production
await this.client.util.syncSlashCommands();