aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/commands/info/pronouns.ts37
-rw-r--r--src/lib/extensions/Util.ts48
-rw-r--r--src/listeners/client/syncslashcommands.ts5
3 files changed, 68 insertions, 22 deletions
diff --git a/src/commands/info/pronouns.ts b/src/commands/info/pronouns.ts
index 07d210f..97cca34 100644
--- a/src/commands/info/pronouns.ts
+++ b/src/commands/info/pronouns.ts
@@ -59,9 +59,17 @@ export default class PronounsCommand extends BotCommand {
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({
@@ -71,7 +79,7 @@ export default class PronounsCommand extends BotCommand {
text: 'Data provided by https://pronoundb.org/'
}
})
- )
+ );
} else {
message.reply({
embeds: [
@@ -83,24 +91,31 @@ export default class PronounsCommand extends BotCommand {
}
})
]
- })
+ });
}
} 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;
}
}
async exec(message: Message, { user }: { user?: User }): Promise<void> {
const u = user || message.author;
- await this.sendResponse(message, u, u.id === message.author.id)
+ await this.sendResponse(message, u, u.id === message.author.id);
}
- 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)
+ 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);
}
-} \ No newline at end of file
+}
diff --git a/src/lib/extensions/Util.ts b/src/lib/extensions/Util.ts
index bd6823f..54df670 100644
--- a/src/lib/extensions/Util.ts
+++ b/src/lib/extensions/Util.ts
@@ -246,10 +246,13 @@ export class Util extends ClientUtil {
}
public async syncSlashCommands(force = false, guild?: string): Promise<void> {
- let fetchedGuild: Guild
+ 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(
@@ -257,9 +260,15 @@ export class Util extends ClientUtil {
)?.execSlash ||
force
) {
- guild === undefined ? await this.client.application.commands.delete(registeredCommand.id) : await fetchedGuild.commands.delete(registeredCommand.id);
+ 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}`:''}}`
+ chalk`{red Deleted slash command ${registeredCommand.name}${
+ guild !== undefined ? ` in guild ${fetchedGuild.name}` : ''
+ }}`
);
}
}
@@ -276,25 +285,44 @@ 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);
+ 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}`:''}}`
+ 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);
+ 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}`:''}}`
+ 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.}`
+ chalk`{red Slash commands not registered${
+ guild !== undefined ? ` in guild ${fetchedGuild.name}` : ''
+ }, see above error.}`
);
}
}
diff --git a/src/listeners/client/syncslashcommands.ts b/src/listeners/client/syncslashcommands.ts
index da42185..febdd1b 100644
--- a/src/listeners/client/syncslashcommands.ts
+++ b/src/listeners/client/syncslashcommands.ts
@@ -10,7 +10,10 @@ export default class CreateSlashCommands extends BotListener {
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();