From dcf325c7fc44f1c89c3b544a87ec89f4195e3a7e Mon Sep 17 00:00:00 2001 From: Mylloon Date: Thu, 21 Jul 2022 23:01:21 +0200 Subject: [PATCH] generic data declaration --- src/commands/misc/ping.ts | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/commands/misc/ping.ts b/src/commands/misc/ping.ts index 4d2e8ff..a995131 100644 --- a/src/commands/misc/ping.ts +++ b/src/commands/misc/ping.ts @@ -1,15 +1,16 @@ import { SlashCommandBuilder } from '@discordjs/builders'; import { Client, CommandInteraction, Message } from 'discord.js'; import { getLocale } from '../../utils/locales'; +import { getFilename } from '../../utils/misc'; export default { data: (client: Client) => { - const path = __filename.split('/'); + const filename = getFilename(__filename); return new SlashCommandBuilder() - .setName(path[path.length - 1].split('.')[0]) - .setDescription(client.locales.get(client.config.default_lang)?.get('c_ping_desc') ?? '?') - .setNameLocalizations(getLocale(client, 'c_ping_name')) - .setDescriptionLocalizations(getLocale(client, 'c_ping_desc')); + .setName(filename) + .setDescription(client.locales.get(client.config.default_lang)?.get(`c_${filename}_desc`) ?? '?') + .setNameLocalizations(getLocale(client, `c_${filename}_name`)) + .setDescriptionLocalizations(getLocale(client, `c_${filename}_desc`)); }, interaction: async (interaction: CommandInteraction, client: Client) => {