aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIRONM00N <64110067+IRONM00N@users.noreply.github.com>2022-05-27 19:14:44 -0400
committerIRONM00N <64110067+IRONM00N@users.noreply.github.com>2022-05-27 19:14:44 -0400
commit2db1d85a24c8a4d7e519d527e5bdb8fa469c4c85 (patch)
tree7a86903c52ff051dca6ce8b1406e0bf0d693e819
parent85623caadc009423a999949880de12a386f335c2 (diff)
downloadtanzanite-2db1d85a24c8a4d7e519d527e5bdb8fa469c4c85.tar.gz
tanzanite-2db1d85a24c8a4d7e519d527e5bdb8fa469c4c85.tar.bz2
tanzanite-2db1d85a24c8a4d7e519d527e5bdb8fa469c4c85.zip
fix: replace '{error}' in retry prompts
-rw-r--r--src/commands/fun/minesweeper.ts2
-rw-r--r--src/commands/leveling/levelRoles.ts56
-rw-r--r--src/lib/extensions/discord-akairo/BushClient.ts34
3 files changed, 49 insertions, 43 deletions
diff --git a/src/commands/fun/minesweeper.ts b/src/commands/fun/minesweeper.ts
index 41daa8e..72551e9 100644
--- a/src/commands/fun/minesweeper.ts
+++ b/src/commands/fun/minesweeper.ts
@@ -56,7 +56,7 @@ export default class MinesweeperCommand extends BushCommand {
id: 'do_not_reveal_first_cell',
description: 'Whether to not reveal the first cell automatically.',
match: 'flag',
- flag: '--doNotRevealFirstCell',
+ flag: ['--doNotRevealFirstCell', 'do_not_reveal_first_cell'],
prompt: 'Would you like to not automatically reveal the first cell?',
slashType: ApplicationCommandOptionType.Boolean,
optional: true
diff --git a/src/commands/leveling/levelRoles.ts b/src/commands/leveling/levelRoles.ts
index 893e602..3d95933 100644
--- a/src/commands/leveling/levelRoles.ts
+++ b/src/commands/leveling/levelRoles.ts
@@ -46,34 +46,20 @@ export default class LevelRolesCommand extends BushCommand {
assert(message.member);
if (!(await message.guild.hasFeature('leveling'))) {
- return await message.util.reply(
- `${util.emojis.error} This command can only be run in servers with the leveling feature enabled.`
- );
+ return await reply(`${util.emojis.error} This command can only be run in servers with the leveling feature enabled.`);
}
- if (args.level < 1) return await message.util.reply(`${util.emojis.error} You cannot set a level role less that 1.`);
+ if (args.level < 1) return await reply(`${util.emojis.error} You cannot set a level role less that 1.`);
if (args.role) {
if (args.role.managed)
- return await message.util.reply({
- content: `${util.emojis.error} You cannot set <@${args.role.id}> as a level role since it is managed.`,
- allowedMentions: AllowedMentions.none()
- });
+ return await reply(`${util.emojis.error} You cannot set <@${args.role.id}> as a level role since it is managed.`);
else if (args.role.id === message.guild.id)
- return await message.util.reply({
- content: `${util.emojis.error} You cannot set the @everyone role as a level role.`,
- allowedMentions: AllowedMentions.none()
- });
+ return await reply(`${util.emojis.error} You cannot set the @everyone role as a level role.`);
else if (args.role.comparePositionTo(message.member.roles.highest) >= 0)
- return await message.util.reply({
- content: `${util.emojis.error} <@${args.role.id}> is higher or equal to your highest role.`,
- allowedMentions: AllowedMentions.none()
- });
+ return await reply(`${util.emojis.error} <@${args.role.id}> is higher or equal to your highest role.`);
else if (args.role.comparePositionTo(message.guild.members.me!.roles.highest) >= 0)
- return await message.util.reply({
- content: `${util.emojis.error} <@${args.role.id}> is higher or equal to my highest role.`,
- allowedMentions: AllowedMentions.none()
- });
+ return await reply(`${util.emojis.error} <@${args.role.id}> is higher or equal to my highest role.`);
}
const oldRoles = Object.freeze(await message.guild.getSetting('levelRoles'));
@@ -88,25 +74,25 @@ export default class LevelRolesCommand extends BushCommand {
const success = await message.guild.setSetting('levelRoles', newRoles, message.member).catch(() => false);
- if (!success) return await message.util.reply(`${util.emojis.error} An error occurred while setting the level roles.`);
+ if (!success) return await reply(`${util.emojis.error} An error occurred while setting the level roles.`);
if (!oldRoles[args.level] && newRoles[args.level]) {
- return await message.util.reply({
- content: `${util.emojis.success} The level role for **${args.level}** is now <@&${newRoles[args.level]}>.`,
- allowedMentions: AllowedMentions.none()
- });
+ return await reply(`${util.emojis.success} The level role for **${args.level}** is now <@&${newRoles[args.level]}>.`);
} else if (oldRoles[args.level] && !newRoles[args.level]) {
- return await message.util.reply({
- content: `${util.emojis.success} The level role for **${args.level}** was <@&${
- oldRoles[args.level]
- }> but is now disabled.`,
- allowedMentions: AllowedMentions.none()
- });
+ return await reply(
+ `${util.emojis.success} The level role for **${args.level}** was <@&${oldRoles[args.level]}> but is now disabled.`
+ );
} else if (oldRoles[args.level] && newRoles[args.level]) {
- return await message.util.reply({
- content: `${util.emojis.success} The level role for **${args.level}** has been updated from <@&${
- oldRoles[args.level]
- }> to <@&${newRoles[args.level]}>.`,
+ return await reply(
+ `${util.emojis.success} The level role for **${args.level}** has been updated from <@&${oldRoles[args.level]}> to <@&${
+ newRoles[args.level]
+ }>.`
+ );
+ }
+
+ function reply(str: string) {
+ return message.util.reply({
+ content: str,
allowedMentions: AllowedMentions.none()
});
}
diff --git a/src/lib/extensions/discord-akairo/BushClient.ts b/src/lib/extensions/discord-akairo/BushClient.ts
index 4df751d..c56c9ad 100644
--- a/src/lib/extensions/discord-akairo/BushClient.ts
+++ b/src/lib/extensions/discord-akairo/BushClient.ts
@@ -22,7 +22,13 @@ import type {
} from '#lib';
import { patch, type PatchedElements } from '@notenoughupdates/events-intercept';
import * as Sentry from '@sentry/node';
-import { AkairoClient, ContextMenuCommandHandler, PromptContentModifier, version as akairoVersion } from 'discord-akairo';
+import {
+ AkairoClient,
+ ArgumentPromptData,
+ ContextMenuCommandHandler,
+ OtherwiseContentSupplier,
+ version as akairoVersion
+} from 'discord-akairo';
import { GatewayIntentBits } from 'discord-api-types/v10';
import {
ActivityType,
@@ -236,13 +242,27 @@ export class BushClient<Ready extends boolean = boolean> extends AkairoClient<Re
automateCategories: true
});
- const modify: PromptContentModifier = async (message, text, data) => {
+ const modify = async (
+ message: Message,
+ text: string | MessagePayload | MessageOptions | OtherwiseContentSupplier,
+ data: ArgumentPromptData,
+ replaceError: boolean
+ ) => {
const ending = '\n\n Type **cancel** to cancel the command';
const options = typeof text === 'function' ? await text(message, data) : text;
- if (typeof options === 'string') return options + ending;
+
+ if (typeof options === 'string')
+ return (replaceError ? options.replace('{error}', this.consts.emojis.error) : options) + ending;
+
if (options instanceof MessagePayload) {
- if (options.options.content) options.options.content += ending;
- } else options.content += ending;
+ if (options.options.content) {
+ if (replaceError) options.options.content = options.options.content.replace('{error}', this.consts.emojis.error);
+ options.options.content += ending;
+ }
+ } else if (options.content) {
+ if (replaceError) options.content = options.content.replace('{error}', this.consts.emojis.error);
+ options.content += ending;
+ }
return options;
};
@@ -262,8 +282,8 @@ export class BushClient<Ready extends boolean = boolean> extends AkairoClient<Re
prompt: {
start: 'Placeholder argument prompt. **If you see this please tell my developers**.',
retry: 'Placeholder failed argument prompt. **If you see this please tell my developers**.',
- modifyStart: (message, text, data) => modify(message, text, data),
- modifyRetry: (message, text, data) => modify(message, text, data),
+ modifyStart: (message, text, data) => modify(message, text, data, false),
+ modifyRetry: (message, text, data) => modify(message, text, data, true),
timeout: ':hourglass: You took too long the command has been cancelled.',
ended: 'You exceeded the maximum amount of tries the command has been cancelled',
cancel: 'The command has been cancelled',