aboutsummaryrefslogtreecommitdiff
path: root/src/lib/extensions/Util.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/extensions/Util.ts')
-rw-r--r--src/lib/extensions/Util.ts64
1 files changed, 52 insertions, 12 deletions
diff --git a/src/lib/extensions/Util.ts b/src/lib/extensions/Util.ts
index 9106020..78fba12 100644
--- a/src/lib/extensions/Util.ts
+++ b/src/lib/extensions/Util.ts
@@ -5,7 +5,12 @@ import { exec } from 'child_process';
import got from 'got';
import { MessageEmbed, GuildMember, User } from 'discord.js';
import { CommandInteractionOption } from 'discord.js';
-import { ApplicationCommandOptionType, APIInteractionDataResolvedGuildMember, APIInteractionDataResolvedChannel, APIRole } from 'discord-api-types';
+import {
+ ApplicationCommandOptionType,
+ APIInteractionDataResolvedGuildMember,
+ APIInteractionDataResolvedChannel,
+ APIRole
+} from 'discord-api-types';
import { GuildChannel } from 'discord.js';
import { Role } from 'discord.js';
import chalk from 'chalk';
@@ -218,7 +223,12 @@ export class Util extends ClientUtil {
author = author.user; // Convert to User if GuildMember
}
let embed = new MessageEmbed().setTimestamp();
- if (author) embed = embed.setAuthor(author.username, author.displayAvatarURL({ dynamic: true }), `https://discord.com/users/${author.id}`);
+ if (author)
+ embed = embed.setAuthor(
+ author.username,
+ author.displayAvatarURL({ dynamic: true }),
+ `https://discord.com/users/${author.id}`
+ );
if (color) embed = embed.setColor(color);
return embed;
}
@@ -232,11 +242,18 @@ 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}` : ''}}`);
+ 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}` : ''
+ }}`
+ );
}
}
@@ -253,20 +270,38 @@ export class Util extends ClientUtil {
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.}`
+ );
}
}
@@ -310,7 +345,12 @@ 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;