From 3c453e4eca78dd42c33e9cac1dada4d32f3c56d0 Mon Sep 17 00:00:00 2001 From: xhyrom Date: Sun, 13 Feb 2022 12:13:47 +0100 Subject: [PATCH] fix: add responses, edit getResponse --- src/handlers/MessageCommandHandler.ts | 3 ++- src/lib/util/Util.ts | 4 ++-- src/responses.json | 3 ++- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/handlers/MessageCommandHandler.ts b/src/handlers/MessageCommandHandler.ts index 0424f8352..e264e7119 100644 --- a/src/handlers/MessageCommandHandler.ts +++ b/src/handlers/MessageCommandHandler.ts @@ -14,7 +14,8 @@ const cooldowns = new Collection>(); const checkValidation = async(arg: MessageArgumentTypes, content: string | MessageAttachment, client: Client, guild: Guild, argument: Argument, channel: TextChannel, user: User) => { if (!content) { - const text = `${user.toString()}, please define argument \`${argument.name}\`, type: ${Util.toPascalCase(ArgumentType[argument.type.toString()])}`; + const text = (await Util.getResponse('ARGUMENT_REQUIRED', { client })).replace('{user}', user.toString()).replace('{name}', argument.name).replace('{type}', Util.toPascalCase(ArgumentType[argument.type.toString()])); + //const text = `${user.toString()}, please define argument \`${argument.name}\`, type: ${Util.toPascalCase(ArgumentType[argument.type.toString()])}`; if (argument.type === ArgumentType.STRING && argument.choices?.length !== 0) { const message = await channel.send({ content: text, diff --git a/src/lib/util/Util.ts b/src/lib/util/Util.ts index 080168a97..062b8ca2e 100644 --- a/src/lib/util/Util.ts +++ b/src/lib/util/Util.ts @@ -118,10 +118,10 @@ export class Util { .replace(new RegExp(/\w/), s => s.toUpperCase()); } - static async getResponse(value: string, interaction: { client: Client | GClient }) { + static async getResponse(value: string, interaction: { client: Client | GClient }): Promise { const languagePlugin = Plugins.get('@gcommands/plugin-language'); - if (languagePlugin !== null) { + if (languagePlugin) { const { LanguageManager } = await import('@gcommands/plugin-language'); const text = LanguageManager.__(interaction, value); diff --git a/src/responses.json b/src/responses.json index a64780373..fb556b5fb 100644 --- a/src/responses.json +++ b/src/responses.json @@ -1,5 +1,6 @@ { "NOT_FOUND": "Looks like that command went to play hide and seek!", "ERROR": "Something went wrong", - "COOLDOWN": "You have to wait {time} before using the {name} again" + "COOLDOWN": "You have to wait {time} before using the {name} again", + "ARGUMENT_REQUIRED": "{user}, please define argument {name}, type: `{type}`" } \ No newline at end of file