Compare commits
No commits in common. "def329bf679dc4ca59a4e5a77d8eac997422d3bf" and "8f0096a73cb764c40cf609ac88d7305ab40a6391" have entirely different histories.
def329bf67
...
8f0096a73c
7 changed files with 12 additions and 27 deletions
|
@ -4,7 +4,7 @@
|
||||||
"description": "Bot discord",
|
"description": "Bot discord",
|
||||||
"main": "src/index.js",
|
"main": "src/index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"main": "rm -r dist 2> /dev/null; npx tsc && node ./dist/index.js",
|
"main": "npx tsc && node ./dist/index.js",
|
||||||
"debug": "npx tsnd --respawn ./src/index.ts",
|
"debug": "npx tsnd --respawn ./src/index.ts",
|
||||||
"lint": "npx eslint src"
|
"lint": "npx eslint src"
|
||||||
},
|
},
|
||||||
|
|
|
@ -1,17 +1,11 @@
|
||||||
import { SlashCommandBuilder } from '@discordjs/builders';
|
import { SlashCommandBuilder } from '@discordjs/builders';
|
||||||
import { Client, CommandInteraction, Message } from 'discord.js';
|
import { Client, CommandInteraction, Message } from 'discord.js';
|
||||||
import { getLocale } from '../../utils/locales';
|
import { getLocale } from '../../utils/locales';
|
||||||
import { getFilename } from '../../utils/misc';
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
data: (client: Client) => {
|
data: (client: Client) => new SlashCommandBuilder()
|
||||||
const filename = getFilename(__filename);
|
.setNameLocalizations(getLocale(client, 'c_ping_name'))
|
||||||
return new SlashCommandBuilder()
|
.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) => {
|
interaction: async (interaction: CommandInteraction, client: Client) => {
|
||||||
const loc = client.locales.get(interaction.locale) ?? client.locales.get(client.config.default_lang);
|
const loc = client.locales.get(interaction.locale) ?? client.locales.get(client.config.default_lang);
|
||||||
|
|
|
@ -6,7 +6,7 @@ export default (interaction: Interaction, client: Client) => {
|
||||||
const command = client.commands.get(interaction.commandName);
|
const command = client.commands.get(interaction.commandName);
|
||||||
if (!command) {
|
if (!command) {
|
||||||
return interaction.reply({
|
return interaction.reply({
|
||||||
content: client.locales.get(interaction.locale)?.get('e_interacreate_no_command'),
|
content: client.locales.get(interaction.locale)?.get('e_interacreate'),
|
||||||
ephemeral: true,
|
ephemeral: true,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
{
|
{
|
||||||
"e_interacreate_no_command": "Sorry, the command probably no longer exists...",
|
"e_interacreate": "Sorry, the command probably no longer exists...",
|
||||||
|
|
||||||
"c_ping_desc": "Pong!",
|
"c_ping_name": "Ping",
|
||||||
|
"c_ping_desc": "Pong",
|
||||||
"c_ping1": "Roundtrip latency",
|
"c_ping1": "Roundtrip latency",
|
||||||
"c_ping2": "Websocket heartbeat"
|
"c_ping2": "Websocket heartbeat"
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
{
|
{
|
||||||
"e_interacreate_no_command": "Désolé, la commande n'existe plus...",
|
"e_interacreate": "Désolé, la commande n'existe plus...",
|
||||||
|
|
||||||
"c_ping1": "Latence totale",
|
"c_ping1": "Latence totale",
|
||||||
"c_ping2": "Latence du Websocket"
|
"c_ping2": "Latence du Websocket"
|
||||||
|
|
|
@ -49,9 +49,10 @@ export const getLocale = (client: Client, text: string) => {
|
||||||
const str = locale.get(text)
|
const str = locale.get(text)
|
||||||
?? client.locales.get(client.config.default_lang)?.get(text);
|
?? client.locales.get(client.config.default_lang)?.get(text);
|
||||||
|
|
||||||
if (str !== undefined) {
|
if (str === undefined) {
|
||||||
data[lang] = str.toLowerCase();
|
throw 'Missing locales';
|
||||||
}
|
}
|
||||||
|
data[lang] = str;
|
||||||
});
|
});
|
||||||
|
|
||||||
return data;
|
return data;
|
||||||
|
|
|
@ -7,14 +7,3 @@
|
||||||
export const logStart = (name: string, status: boolean) => {
|
export const logStart = (name: string, status: boolean) => {
|
||||||
return `> ${name} ${status === true ? '✅' : '❌'}`;
|
return `> ${name} ${status === true ? '✅' : '❌'}`;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* Filename without path and extension
|
|
||||||
* @param path __filename
|
|
||||||
* @returns string
|
|
||||||
*/
|
|
||||||
export const getFilename = (path: string) => {
|
|
||||||
const path_list = path.split('/');
|
|
||||||
|
|
||||||
return path_list[path_list.length - 1].split('.')[0];
|
|
||||||
};
|
|
||||||
|
|
Loading…
Reference in a new issue