Skip to content

Commit

Permalink
fix: add responses, edit getResponse
Browse files Browse the repository at this point in the history
  • Loading branch information
xhyrom committed Feb 13, 2022
1 parent b8c5dfc commit 3c453e4
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/handlers/MessageCommandHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ const cooldowns = new Collection<string, Collection<string, number>>();

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,
Expand Down
4 changes: 2 additions & 2 deletions src/lib/util/Util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string> {
const languagePlugin = Plugins.get('@gcommands/plugin-language');

if (languagePlugin !== null) {
if (languagePlugin) {
const { LanguageManager } = await import('@gcommands/plugin-language');

const text = LanguageManager.__(interaction, value);
Expand Down
3 changes: 2 additions & 1 deletion src/responses.json
Original file line number Diff line number Diff line change
@@ -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}`"
}

0 comments on commit 3c453e4

Please sign in to comment.