mirror of
https://github.com/Hessenuk/DiscordTickets.git
synced 2024-12-23 00:03:09 +02:00
refactor: simplify commands i18n
This commit is contained in:
parent
c6f1261478
commit
1843400004
@ -37,9 +37,9 @@
|
||||
"@discord-tickets/settings": "^1.1.5",
|
||||
"@eartharoid/dbf": "^0.3.3",
|
||||
"@eartharoid/dtf": "^2.0.1",
|
||||
"@eartharoid/i18n": "^1.1.0",
|
||||
"@eartharoid/i18n": "^1.2.1",
|
||||
"@fastify/cookie": "^6.0.0",
|
||||
"@fastify/cors": "^8.1.0",
|
||||
"@fastify/cors": "^8.1.1",
|
||||
"@fastify/http-proxy": "^8.2.3",
|
||||
"@fastify/jwt": "^5.0.1",
|
||||
"@fastify/oauth2": "^5.1.0",
|
||||
@ -67,7 +67,7 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"all-contributors-cli": "^6.24.0",
|
||||
"eslint": "^8.25.0",
|
||||
"eslint": "^8.26.0",
|
||||
"eslint-plugin-unused-imports": "^2.0.0",
|
||||
"nodemon": "^2.0.20"
|
||||
},
|
||||
|
@ -3,48 +3,32 @@ const { ApplicationCommandOptionType } = require('discord.js');
|
||||
|
||||
module.exports = class AddSlashCommand extends SlashCommand {
|
||||
constructor(client, options) {
|
||||
const descriptionLocalizations = {};
|
||||
client.i18n.locales.forEach(l => (descriptionLocalizations[l] = client.i18n.getMessage(l, 'commands.slash.add.description')));
|
||||
|
||||
const nameLocalizations = {};
|
||||
client.i18n.locales.forEach(l => (nameLocalizations[l] = client.i18n.getMessage(l, 'commands.slash.add.name')));
|
||||
|
||||
let opts = [
|
||||
{
|
||||
name: 'member',
|
||||
required: true,
|
||||
type: ApplicationCommandOptionType.User,
|
||||
},
|
||||
{
|
||||
autocomplete: true,
|
||||
name: 'ticket',
|
||||
required: false,
|
||||
type: ApplicationCommandOptionType.String,
|
||||
},
|
||||
];
|
||||
opts = opts.map(o => {
|
||||
const descriptionLocalizations = {};
|
||||
client.i18n.locales.forEach(l => (descriptionLocalizations[l] = client.i18n.getMessage(l, `commands.slash.add.options.${o.name}.description`)));
|
||||
|
||||
const nameLocalizations = {};
|
||||
client.i18n.locales.forEach(l => (nameLocalizations[l] = client.i18n.getMessage(l, `commands.slash.add.options.${o.name}.name`)));
|
||||
|
||||
return {
|
||||
...o,
|
||||
description: descriptionLocalizations['en-GB'],
|
||||
descriptionLocalizations,
|
||||
nameLocalizations: nameLocalizations,
|
||||
};
|
||||
});
|
||||
|
||||
const name = 'add';
|
||||
super(client, {
|
||||
...options,
|
||||
description: descriptionLocalizations['en-GB'],
|
||||
descriptionLocalizations,
|
||||
description: client.i18n.getMessage(null, `commands.slash.${name}.description`),
|
||||
descriptionLocalizations: client.i18n.getAllMessages(`commands.slash.${name}.description`),
|
||||
dmPermission: false,
|
||||
name: nameLocalizations['en-GB'],
|
||||
nameLocalizations,
|
||||
options: opts,
|
||||
name,
|
||||
nameLocalizations: client.i18n.getAllMessages(`commands.slash.${name}.name`),
|
||||
options: [
|
||||
{
|
||||
name: 'member',
|
||||
required: true,
|
||||
type: ApplicationCommandOptionType.User,
|
||||
},
|
||||
{
|
||||
autocomplete: true,
|
||||
name: 'ticket',
|
||||
required: false,
|
||||
type: ApplicationCommandOptionType.String,
|
||||
},
|
||||
].map(option => {
|
||||
option.descriptionLocalizations = client.i18n.getAllMessages(`commands.slash.${name}.options.${option.name}.description`);
|
||||
option.description = option.descriptionLocalizations['en-GB'];
|
||||
option.nameLocalizations = client.i18n.getAllMessages(`commands.slash.${name}.options.${option.name}.name`);
|
||||
return option;
|
||||
}),
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -2,19 +2,14 @@ const { SlashCommand } = require('@eartharoid/dbf');
|
||||
|
||||
module.exports = class ClaimSlashCommand extends SlashCommand {
|
||||
constructor(client, options) {
|
||||
const descriptionLocalizations = {};
|
||||
client.i18n.locales.forEach(l => (descriptionLocalizations[l] = client.i18n.getMessage(l, 'commands.slash.claim.description')));
|
||||
|
||||
const nameLocalizations = {};
|
||||
client.i18n.locales.forEach(l => (nameLocalizations[l] = client.i18n.getMessage(l, 'commands.slash.claim.name')));
|
||||
|
||||
const name = 'claim';
|
||||
super(client, {
|
||||
...options,
|
||||
description: descriptionLocalizations['en-GB'],
|
||||
descriptionLocalizations,
|
||||
description: client.i18n.getMessage(null, `commands.slash.${name}.description`),
|
||||
descriptionLocalizations: client.i18n.getAllMessages(`commands.slash.${name}.description`),
|
||||
dmPermission: false,
|
||||
name: nameLocalizations['en-GB'],
|
||||
nameLocalizations,
|
||||
name,
|
||||
nameLocalizations: client.i18n.getAllMessages(`commands.slash.${name}.name`),
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -3,48 +3,32 @@ const { ApplicationCommandOptionType } = require('discord.js');
|
||||
|
||||
module.exports = class CloseSlashCommand extends SlashCommand {
|
||||
constructor(client, options) {
|
||||
const descriptionLocalizations = {};
|
||||
client.i18n.locales.forEach(l => (descriptionLocalizations[l] = client.i18n.getMessage(l, 'commands.slash.close.description')));
|
||||
|
||||
const nameLocalizations = {};
|
||||
client.i18n.locales.forEach(l => (nameLocalizations[l] = client.i18n.getMessage(l, 'commands.slash.close.name')));
|
||||
|
||||
let opts = [
|
||||
{
|
||||
name: 'reason',
|
||||
required: false,
|
||||
type: ApplicationCommandOptionType.String,
|
||||
},
|
||||
{
|
||||
autocomplete: true,
|
||||
name: 'ticket',
|
||||
required: false,
|
||||
type: ApplicationCommandOptionType.String,
|
||||
},
|
||||
];
|
||||
opts = opts.map(o => {
|
||||
const descriptionLocalizations = {};
|
||||
client.i18n.locales.forEach(l => (descriptionLocalizations[l] = client.i18n.getMessage(l, `commands.slash.close.options.${o.name}.description`)));
|
||||
|
||||
const nameLocalizations = {};
|
||||
client.i18n.locales.forEach(l => (nameLocalizations[l] = client.i18n.getMessage(l, `commands.slash.close.options.${o.name}.name`)));
|
||||
|
||||
return {
|
||||
...o,
|
||||
description: descriptionLocalizations['en-GB'],
|
||||
descriptionLocalizations,
|
||||
nameLocalizations: nameLocalizations,
|
||||
};
|
||||
});
|
||||
|
||||
const name = 'close';
|
||||
super(client, {
|
||||
...options,
|
||||
description: descriptionLocalizations['en-GB'],
|
||||
descriptionLocalizations,
|
||||
description: client.i18n.getMessage(null, `commands.slash.${name}.description`),
|
||||
descriptionLocalizations: client.i18n.getAllMessages(`commands.slash.${name}.description`),
|
||||
dmPermission: false,
|
||||
name: nameLocalizations['en-GB'],
|
||||
nameLocalizations,
|
||||
options: opts,
|
||||
name,
|
||||
nameLocalizations: client.i18n.getAllMessages(`commands.slash.${name}.name`),
|
||||
options: [
|
||||
{
|
||||
name: 'reason',
|
||||
required: false,
|
||||
type: ApplicationCommandOptionType.String,
|
||||
},
|
||||
{
|
||||
autocomplete: true,
|
||||
name: 'ticket',
|
||||
required: false,
|
||||
type: ApplicationCommandOptionType.String,
|
||||
},
|
||||
].map(option => {
|
||||
option.descriptionLocalizations = client.i18n.getAllMessages(`commands.slash.${name}.options.${option.name}.description`);
|
||||
option.description = option.descriptionLocalizations['en-GB'];
|
||||
option.nameLocalizations = client.i18n.getAllMessages(`commands.slash.${name}.options.${option.name}.name`);
|
||||
return option;
|
||||
}),
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -12,59 +12,43 @@ const ms = require('ms');
|
||||
|
||||
module.exports = class ForceCloseSlashCommand extends SlashCommand {
|
||||
constructor(client, options) {
|
||||
const descriptionLocalizations = {};
|
||||
client.i18n.locales.forEach(l => (descriptionLocalizations[l] = client.i18n.getMessage(l, 'commands.slash.force-close.description')));
|
||||
|
||||
const nameLocalizations = {};
|
||||
client.i18n.locales.forEach(l => (nameLocalizations[l] = client.i18n.getMessage(l, 'commands.slash.force-close.name')));
|
||||
|
||||
let opts = [
|
||||
{
|
||||
autocomplete: true,
|
||||
name: 'category',
|
||||
required: false,
|
||||
type: ApplicationCommandOptionType.Integer,
|
||||
},
|
||||
{
|
||||
name: 'reason',
|
||||
required: false,
|
||||
type: ApplicationCommandOptionType.String,
|
||||
},
|
||||
{
|
||||
autocomplete: true,
|
||||
name: 'ticket',
|
||||
required: false,
|
||||
type: ApplicationCommandOptionType.String,
|
||||
},
|
||||
{
|
||||
name: 'time',
|
||||
required: false,
|
||||
type: ApplicationCommandOptionType.String,
|
||||
},
|
||||
];
|
||||
opts = opts.map(o => {
|
||||
const descriptionLocalizations = {};
|
||||
client.i18n.locales.forEach(l => (descriptionLocalizations[l] = client.i18n.getMessage(l, `commands.slash.force-close.options.${o.name}.description`)));
|
||||
|
||||
const nameLocalizations = {};
|
||||
client.i18n.locales.forEach(l => (nameLocalizations[l] = client.i18n.getMessage(l, `commands.slash.force-close.options.${o.name}.name`)));
|
||||
|
||||
return {
|
||||
...o,
|
||||
description: descriptionLocalizations['en-GB'],
|
||||
descriptionLocalizations,
|
||||
nameLocalizations: nameLocalizations,
|
||||
};
|
||||
});
|
||||
|
||||
const name = 'force-close';
|
||||
super(client, {
|
||||
...options,
|
||||
description: descriptionLocalizations['en-GB'],
|
||||
descriptionLocalizations,
|
||||
description: client.i18n.getMessage(null, `commands.slash.${name}.description`),
|
||||
descriptionLocalizations: client.i18n.getAllMessages(`commands.slash.${name}.description`),
|
||||
dmPermission: false,
|
||||
name: nameLocalizations['en-GB'],
|
||||
nameLocalizations,
|
||||
options: opts,
|
||||
name,
|
||||
nameLocalizations: client.i18n.getAllMessages(`commands.slash.${name}.name`),
|
||||
options: [
|
||||
{
|
||||
autocomplete: true,
|
||||
name: 'category',
|
||||
required: false,
|
||||
type: ApplicationCommandOptionType.Integer,
|
||||
},
|
||||
{
|
||||
name: 'reason',
|
||||
required: false,
|
||||
type: ApplicationCommandOptionType.String,
|
||||
},
|
||||
{
|
||||
autocomplete: true,
|
||||
name: 'ticket',
|
||||
required: false,
|
||||
type: ApplicationCommandOptionType.String,
|
||||
},
|
||||
{
|
||||
name: 'time',
|
||||
required: false,
|
||||
type: ApplicationCommandOptionType.String,
|
||||
},
|
||||
].map(option => {
|
||||
option.descriptionLocalizations = client.i18n.getAllMessages(`commands.slash.${name}.options.${option.name}.description`);
|
||||
option.description = option.descriptionLocalizations['en-GB'];
|
||||
option.nameLocalizations = client.i18n.getAllMessages(`commands.slash.${name}.options.${option.name}.name`);
|
||||
return option;
|
||||
}),
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -5,19 +5,14 @@ const { version } = require('../../../package.json');
|
||||
|
||||
module.exports = class ClaimSlashCommand extends SlashCommand {
|
||||
constructor(client, options) {
|
||||
const descriptionLocalizations = {};
|
||||
client.i18n.locales.forEach(l => (descriptionLocalizations[l] = client.i18n.getMessage(l, 'commands.slash.help.description')));
|
||||
|
||||
const nameLocalizations = {};
|
||||
client.i18n.locales.forEach(l => (nameLocalizations[l] = client.i18n.getMessage(l, 'commands.slash.help.name')));
|
||||
|
||||
const name = 'help';
|
||||
super(client, {
|
||||
...options,
|
||||
description: descriptionLocalizations['en-GB'],
|
||||
descriptionLocalizations,
|
||||
description: client.i18n.getMessage(null, `commands.slash.${name}.description`),
|
||||
descriptionLocalizations: client.i18n.getAllMessages(`commands.slash.${name}.description`),
|
||||
dmPermission: false,
|
||||
name: nameLocalizations['en-GB'],
|
||||
nameLocalizations,
|
||||
name,
|
||||
nameLocalizations: client.i18n.getAllMessages(`commands.slash.${name}.name`),
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -3,43 +3,27 @@ const { ApplicationCommandOptionType } = require('discord.js');
|
||||
|
||||
module.exports = class MoveSlashCommand extends SlashCommand {
|
||||
constructor(client, options) {
|
||||
const descriptionLocalizations = {};
|
||||
client.i18n.locales.forEach(l => (descriptionLocalizations[l] = client.i18n.getMessage(l, 'commands.slash.move.description')));
|
||||
|
||||
const nameLocalizations = {};
|
||||
client.i18n.locales.forEach(l => (nameLocalizations[l] = client.i18n.getMessage(l, 'commands.slash.move.name')));
|
||||
|
||||
let opts = [
|
||||
{
|
||||
autocomplete: true,
|
||||
name: 'category',
|
||||
required: true,
|
||||
type: ApplicationCommandOptionType.Integer,
|
||||
},
|
||||
];
|
||||
opts = opts.map(o => {
|
||||
const descriptionLocalizations = {};
|
||||
client.i18n.locales.forEach(l => (descriptionLocalizations[l] = client.i18n.getMessage(l, `commands.slash.move.options.${o.name}.description`)));
|
||||
|
||||
const nameLocalizations = {};
|
||||
client.i18n.locales.forEach(l => (nameLocalizations[l] = client.i18n.getMessage(l, `commands.slash.move.options.${o.name}.name`)));
|
||||
|
||||
return {
|
||||
...o,
|
||||
description: descriptionLocalizations['en-GB'],
|
||||
descriptionLocalizations,
|
||||
nameLocalizations: nameLocalizations,
|
||||
};
|
||||
});
|
||||
|
||||
const name = 'move';
|
||||
super(client, {
|
||||
...options,
|
||||
description: descriptionLocalizations['en-GB'],
|
||||
descriptionLocalizations,
|
||||
description: client.i18n.getMessage(null, `commands.slash.${name}.description`),
|
||||
descriptionLocalizations: client.i18n.getAllMessages(`commands.slash.${name}.description`),
|
||||
dmPermission: false,
|
||||
name: nameLocalizations['en-GB'],
|
||||
nameLocalizations,
|
||||
options: opts,
|
||||
name,
|
||||
nameLocalizations: client.i18n.getAllMessages(`commands.slash.${name}.name`),
|
||||
options: [
|
||||
{
|
||||
autocomplete: true,
|
||||
name: 'category',
|
||||
required: true,
|
||||
type: ApplicationCommandOptionType.Integer,
|
||||
},
|
||||
].map(option => {
|
||||
option.descriptionLocalizations = client.i18n.getAllMessages(`commands.slash.${name}.options.${option.name}.description`);
|
||||
option.description = option.descriptionLocalizations['en-GB'];
|
||||
option.nameLocalizations = client.i18n.getAllMessages(`commands.slash.${name}.options.${option.name}.name`);
|
||||
return option;
|
||||
}),
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -4,43 +4,27 @@ const { useGuild } = require('../../lib/tickets/utils');
|
||||
|
||||
module.exports = class NewSlashCommand extends SlashCommand {
|
||||
constructor(client, options) {
|
||||
const descriptionLocalizations = {};
|
||||
client.i18n.locales.forEach(l => (descriptionLocalizations[l] = client.i18n.getMessage(l, 'commands.slash.new.description')));
|
||||
|
||||
const nameLocalizations = {};
|
||||
client.i18n.locales.forEach(l => (nameLocalizations[l] = client.i18n.getMessage(l, 'commands.slash.new.name')));
|
||||
|
||||
let opts = [
|
||||
{
|
||||
autocomplete: true,
|
||||
name: 'references',
|
||||
required: false,
|
||||
type: ApplicationCommandOptionType.String,
|
||||
},
|
||||
];
|
||||
opts = opts.map(o => {
|
||||
const descriptionLocalizations = {};
|
||||
client.i18n.locales.forEach(l => (descriptionLocalizations[l] = client.i18n.getMessage(l, `commands.slash.new.options.${o.name}.description`)));
|
||||
|
||||
const nameLocalizations = {};
|
||||
client.i18n.locales.forEach(l => (nameLocalizations[l] = client.i18n.getMessage(l, `commands.slash.new.options.${o.name}.name`)));
|
||||
|
||||
return {
|
||||
...o,
|
||||
description: descriptionLocalizations['en-GB'],
|
||||
descriptionLocalizations,
|
||||
nameLocalizations: nameLocalizations,
|
||||
};
|
||||
});
|
||||
|
||||
const name = 'new';
|
||||
super(client, {
|
||||
...options,
|
||||
description: descriptionLocalizations['en-GB'],
|
||||
descriptionLocalizations,
|
||||
description: client.i18n.getMessage(null, `commands.slash.${name}.description`),
|
||||
descriptionLocalizations: client.i18n.getAllMessages(`commands.slash.${name}.description`),
|
||||
dmPermission: false,
|
||||
name: nameLocalizations['en-GB'],
|
||||
nameLocalizations,
|
||||
options: opts,
|
||||
name,
|
||||
nameLocalizations: client.i18n.getAllMessages(`commands.slash.${name}.name`),
|
||||
options: [
|
||||
{
|
||||
autocomplete: true,
|
||||
name: 'references',
|
||||
required: false,
|
||||
type: ApplicationCommandOptionType.String,
|
||||
},
|
||||
].map(option => {
|
||||
option.descriptionLocalizations = client.i18n.getAllMessages(`commands.slash.${name}.options.${option.name}.description`);
|
||||
option.description = option.descriptionLocalizations['en-GB'];
|
||||
option.nameLocalizations = client.i18n.getAllMessages(`commands.slash.${name}.options.${option.name}.name`);
|
||||
return option;
|
||||
}),
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -5,55 +5,34 @@ const { logTicketEvent } = require('../../lib/logging');
|
||||
|
||||
module.exports = class PrioritySlashCommand extends SlashCommand {
|
||||
constructor(client, options) {
|
||||
const descriptionLocalizations = {};
|
||||
client.i18n.locales.forEach(l => (descriptionLocalizations[l] = client.i18n.getMessage(l, 'commands.slash.priority.description')));
|
||||
|
||||
const nameLocalizations = {};
|
||||
client.i18n.locales.forEach(l => (nameLocalizations[l] = client.i18n.getMessage(l, 'commands.slash.priority.name')));
|
||||
|
||||
let opts = [
|
||||
{
|
||||
choices: ['HIGH', 'MEDIUM', 'LOW'],
|
||||
name: 'priority',
|
||||
required: true,
|
||||
type: ApplicationCommandOptionType.String,
|
||||
},
|
||||
];
|
||||
opts = opts.map(o => {
|
||||
const descriptionLocalizations = {};
|
||||
client.i18n.locales.forEach(l => (descriptionLocalizations[l] = client.i18n.getMessage(l, `commands.slash.priority.options.${o.name}.description`)));
|
||||
|
||||
const nameLocalizations = {};
|
||||
client.i18n.locales.forEach(l => (nameLocalizations[l] = client.i18n.getMessage(l, `commands.slash.priority.options.${o.name}.name`)));
|
||||
|
||||
if (o.choices) {
|
||||
o.choices = o.choices.map(c => {
|
||||
const nameLocalizations = {};
|
||||
client.i18n.locales.forEach(l => (nameLocalizations[l] = client.i18n.getMessage(l, `commands.slash.priority.options.${o.name}.choices.${c}`)));
|
||||
return {
|
||||
name: nameLocalizations['en-GB'],
|
||||
nameLocalizations: nameLocalizations,
|
||||
value: c,
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
return {
|
||||
...o,
|
||||
description: descriptionLocalizations['en-GB'],
|
||||
descriptionLocalizations,
|
||||
nameLocalizations: nameLocalizations,
|
||||
};
|
||||
});
|
||||
|
||||
const name = 'priority';
|
||||
super(client, {
|
||||
...options,
|
||||
description: descriptionLocalizations['en-GB'],
|
||||
descriptionLocalizations,
|
||||
description: client.i18n.getMessage(null, `commands.slash.${name}.description`),
|
||||
descriptionLocalizations: client.i18n.getAllMessages(`commands.slash.${name}.description`),
|
||||
dmPermission: false,
|
||||
name: nameLocalizations['en-GB'],
|
||||
nameLocalizations,
|
||||
options: opts,
|
||||
name,
|
||||
nameLocalizations: client.i18n.getAllMessages(`commands.slash.${name}.name`),
|
||||
options: [
|
||||
{
|
||||
choices: ['HIGH', 'MEDIUM', 'LOW'],
|
||||
name: 'priority',
|
||||
required: true,
|
||||
type: ApplicationCommandOptionType.String,
|
||||
},
|
||||
].map(option => {
|
||||
option.descriptionLocalizations = client.i18n.getAllMessages(`commands.slash.${name}.options.${option.name}.description`);
|
||||
option.description = option.descriptionLocalizations['en-GB'];
|
||||
option.nameLocalizations = client.i18n.getAllMessages(`commands.slash.${name}.options.${option.name}.name`);
|
||||
if (option.choices) {
|
||||
option.choices = option.choices.map(choice => ({
|
||||
name: client.i18n.getMessage(null, `commands.slash.priority.options.${option.name}.choices.${choice}`),
|
||||
nameLocalizations: client.i18n.getAllMessages(`commands.slash.priority.options.${option.name}.choices.${choice}`),
|
||||
value: choice,
|
||||
}));
|
||||
}
|
||||
return option;
|
||||
}),
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -2,19 +2,14 @@ const { SlashCommand } = require('@eartharoid/dbf');
|
||||
|
||||
module.exports = class ReleaseSlashCommand extends SlashCommand {
|
||||
constructor(client, options) {
|
||||
const descriptionLocalizations = {};
|
||||
client.i18n.locales.forEach(l => (descriptionLocalizations[l] = client.i18n.getMessage(l, 'commands.slash.release.description')));
|
||||
|
||||
const nameLocalizations = {};
|
||||
client.i18n.locales.forEach(l => (nameLocalizations[l] = client.i18n.getMessage(l, 'commands.slash.release.name')));
|
||||
|
||||
const name = 'release';
|
||||
super(client, {
|
||||
...options,
|
||||
description: descriptionLocalizations['en-GB'],
|
||||
descriptionLocalizations,
|
||||
description: client.i18n.getMessage(null, `commands.slash.${name}.description`),
|
||||
descriptionLocalizations: client.i18n.getAllMessages(`commands.slash.${name}.description`),
|
||||
dmPermission: false,
|
||||
name: nameLocalizations['en-GB'],
|
||||
nameLocalizations,
|
||||
name,
|
||||
nameLocalizations: client.i18n.getAllMessages(`commands.slash.${name}.name`),
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -3,48 +3,32 @@ const { ApplicationCommandOptionType } = require('discord.js');
|
||||
|
||||
module.exports = class RemoveSlashCommand extends SlashCommand {
|
||||
constructor(client, options) {
|
||||
const descriptionLocalizations = {};
|
||||
client.i18n.locales.forEach(l => (descriptionLocalizations[l] = client.i18n.getMessage(l, 'commands.slash.remove.description')));
|
||||
|
||||
const nameLocalizations = {};
|
||||
client.i18n.locales.forEach(l => (nameLocalizations[l] = client.i18n.getMessage(l, 'commands.slash.remove.name')));
|
||||
|
||||
let opts = [
|
||||
{
|
||||
name: 'member',
|
||||
required: true,
|
||||
type: ApplicationCommandOptionType.User,
|
||||
},
|
||||
{
|
||||
autocomplete: true,
|
||||
name: 'ticket',
|
||||
required: false,
|
||||
type: ApplicationCommandOptionType.String,
|
||||
},
|
||||
];
|
||||
opts = opts.map(o => {
|
||||
const descriptionLocalizations = {};
|
||||
client.i18n.locales.forEach(l => (descriptionLocalizations[l] = client.i18n.getMessage(l, `commands.slash.remove.options.${o.name}.description`)));
|
||||
|
||||
const nameLocalizations = {};
|
||||
client.i18n.locales.forEach(l => (nameLocalizations[l] = client.i18n.getMessage(l, `commands.slash.remove.options.${o.name}.name`)));
|
||||
|
||||
return {
|
||||
...o,
|
||||
description: descriptionLocalizations['en-GB'],
|
||||
descriptionLocalizations,
|
||||
nameLocalizations: nameLocalizations,
|
||||
};
|
||||
});
|
||||
|
||||
const name = 'remove';
|
||||
super(client, {
|
||||
...options,
|
||||
description: descriptionLocalizations['en-GB'],
|
||||
descriptionLocalizations,
|
||||
description: client.i18n.getMessage(null, `commands.slash.${name}.description`),
|
||||
descriptionLocalizations: client.i18n.getAllMessages(`commands.slash.${name}.description`),
|
||||
dmPermission: false,
|
||||
name: nameLocalizations['en-GB'],
|
||||
nameLocalizations,
|
||||
options: opts,
|
||||
name,
|
||||
nameLocalizations: client.i18n.getAllMessages(`commands.slash.${name}.name`),
|
||||
options: [
|
||||
{
|
||||
name: 'member',
|
||||
required: true,
|
||||
type: ApplicationCommandOptionType.User,
|
||||
},
|
||||
{
|
||||
autocomplete: true,
|
||||
name: 'ticket',
|
||||
required: false,
|
||||
type: ApplicationCommandOptionType.String,
|
||||
},
|
||||
].map(option => {
|
||||
option.descriptionLocalizations = client.i18n.getAllMessages(`commands.slash.${name}.options.${option.name}.description`);
|
||||
option.description = option.descriptionLocalizations['en-GB'];
|
||||
option.nameLocalizations = client.i18n.getAllMessages(`commands.slash.${name}.options.${option.name}.name`);
|
||||
return option;
|
||||
}),
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -4,48 +4,32 @@ const ExtendedEmbedBuilder = require('../../lib/embed');
|
||||
|
||||
module.exports = class TagSlashCommand extends SlashCommand {
|
||||
constructor(client, options) {
|
||||
const descriptionLocalizations = {};
|
||||
client.i18n.locales.forEach(l => (descriptionLocalizations[l] = client.i18n.getMessage(l, 'commands.slash.tag.description')));
|
||||
|
||||
const nameLocalizations = {};
|
||||
client.i18n.locales.forEach(l => (nameLocalizations[l] = client.i18n.getMessage(l, 'commands.slash.tag.name')));
|
||||
|
||||
let opts = [
|
||||
{
|
||||
autocomplete: true,
|
||||
name: 'tag',
|
||||
required: true,
|
||||
type: ApplicationCommandOptionType.Integer,
|
||||
},
|
||||
{
|
||||
name: 'for',
|
||||
required: false,
|
||||
type: ApplicationCommandOptionType.User,
|
||||
},
|
||||
];
|
||||
opts = opts.map(o => {
|
||||
const descriptionLocalizations = {};
|
||||
client.i18n.locales.forEach(l => (descriptionLocalizations[l] = client.i18n.getMessage(l, `commands.slash.tag.options.${o.name}.description`)));
|
||||
|
||||
const nameLocalizations = {};
|
||||
client.i18n.locales.forEach(l => (nameLocalizations[l] = client.i18n.getMessage(l, `commands.slash.tag.options.${o.name}.name`)));
|
||||
|
||||
return {
|
||||
...o,
|
||||
description: descriptionLocalizations['en-GB'],
|
||||
descriptionLocalizations,
|
||||
nameLocalizations: nameLocalizations,
|
||||
};
|
||||
});
|
||||
|
||||
const name = 'tag';
|
||||
super(client, {
|
||||
...options,
|
||||
description: descriptionLocalizations['en-GB'],
|
||||
descriptionLocalizations,
|
||||
description: client.i18n.getMessage(null, `commands.slash.${name}.description`),
|
||||
descriptionLocalizations: client.i18n.getAllMessages(`commands.slash.${name}.description`),
|
||||
dmPermission: false,
|
||||
name: nameLocalizations['en-GB'],
|
||||
nameLocalizations,
|
||||
options: opts,
|
||||
name,
|
||||
nameLocalizations: client.i18n.getAllMessages(`commands.slash.${name}.name`),
|
||||
options: [
|
||||
{
|
||||
autocomplete: true,
|
||||
name: 'tag',
|
||||
required: true,
|
||||
type: ApplicationCommandOptionType.Integer,
|
||||
},
|
||||
{
|
||||
name: 'for',
|
||||
required: false,
|
||||
type: ApplicationCommandOptionType.User,
|
||||
},
|
||||
].map(option => {
|
||||
option.descriptionLocalizations = client.i18n.getAllMessages(`commands.slash.${name}.options.${option.name}.description`);
|
||||
option.description = option.descriptionLocalizations['en-GB'];
|
||||
option.nameLocalizations = client.i18n.getAllMessages(`commands.slash.${name}.options.${option.name}.name`);
|
||||
return option;
|
||||
}),
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -7,42 +7,26 @@ const { decrypt } = new Cryptr(process.env.ENCRYPTION_KEY);
|
||||
|
||||
module.exports = class TicketsSlashCommand extends SlashCommand {
|
||||
constructor(client, options) {
|
||||
const descriptionLocalizations = {};
|
||||
client.i18n.locales.forEach(l => (descriptionLocalizations[l] = client.i18n.getMessage(l, 'commands.slash.tickets.description')));
|
||||
|
||||
const nameLocalizations = {};
|
||||
client.i18n.locales.forEach(l => (nameLocalizations[l] = client.i18n.getMessage(l, 'commands.slash.tickets.name')));
|
||||
|
||||
let opts = [
|
||||
{
|
||||
name: 'member',
|
||||
required: false,
|
||||
type: ApplicationCommandOptionType.User,
|
||||
},
|
||||
];
|
||||
opts = opts.map(o => {
|
||||
const descriptionLocalizations = {};
|
||||
client.i18n.locales.forEach(l => (descriptionLocalizations[l] = client.i18n.getMessage(l, `commands.slash.tickets.options.${o.name}.description`)));
|
||||
|
||||
const nameLocalizations = {};
|
||||
client.i18n.locales.forEach(l => (nameLocalizations[l] = client.i18n.getMessage(l, `commands.slash.tickets.options.${o.name}.name`)));
|
||||
|
||||
return {
|
||||
...o,
|
||||
description: descriptionLocalizations['en-GB'],
|
||||
descriptionLocalizations,
|
||||
nameLocalizations: nameLocalizations,
|
||||
};
|
||||
});
|
||||
|
||||
const name = 'tickets';
|
||||
super(client, {
|
||||
...options,
|
||||
description: descriptionLocalizations['en-GB'],
|
||||
descriptionLocalizations,
|
||||
description: client.i18n.getMessage(null, `commands.slash.${name}.description`),
|
||||
descriptionLocalizations: client.i18n.getAllMessages(`commands.slash.${name}.description`),
|
||||
dmPermission: false,
|
||||
name: nameLocalizations['en-GB'],
|
||||
nameLocalizations,
|
||||
options: opts,
|
||||
name,
|
||||
nameLocalizations: client.i18n.getAllMessages(`commands.slash.${name}.name`),
|
||||
options: [
|
||||
{
|
||||
name: 'member',
|
||||
required: false,
|
||||
type: ApplicationCommandOptionType.User,
|
||||
},
|
||||
].map(option => {
|
||||
option.descriptionLocalizations = client.i18n.getAllMessages(`commands.slash.${name}.options.${option.name}.description`);
|
||||
option.description = option.descriptionLocalizations['en-GB'];
|
||||
option.nameLocalizations = client.i18n.getAllMessages(`commands.slash.${name}.options.${option.name}.name`);
|
||||
return option;
|
||||
}),
|
||||
});
|
||||
}
|
||||
|
||||
@ -124,6 +108,7 @@ module.exports = class TicketsSlashCommand extends SlashCommand {
|
||||
}).join('\n'),
|
||||
});
|
||||
}
|
||||
// TODO: add portal URL to view all (this list is limited to the last 10)
|
||||
|
||||
const embed = new ExtendedEmbedBuilder({
|
||||
iconURL: interaction.guild.iconURL(),
|
||||
|
@ -11,19 +11,14 @@ const ExtendedEmbedBuilder = require('../../lib/embed');
|
||||
|
||||
module.exports = class TopicSlashCommand extends SlashCommand {
|
||||
constructor(client, options) {
|
||||
const descriptionLocalizations = {};
|
||||
client.i18n.locales.forEach(l => (descriptionLocalizations[l] = client.i18n.getMessage(l, 'commands.slash.topic.description')));
|
||||
|
||||
const nameLocalizations = {};
|
||||
client.i18n.locales.forEach(l => (nameLocalizations[l] = client.i18n.getMessage(l, 'commands.slash.topic.name')));
|
||||
|
||||
const name = 'topic';
|
||||
super(client, {
|
||||
...options,
|
||||
description: descriptionLocalizations['en-GB'],
|
||||
descriptionLocalizations,
|
||||
description: client.i18n.getMessage(null, `commands.slash.${name}.description`),
|
||||
descriptionLocalizations: client.i18n.getAllMessages(`commands.slash.${name}.description`),
|
||||
dmPermission: false,
|
||||
name: nameLocalizations['en-GB'],
|
||||
nameLocalizations,
|
||||
name,
|
||||
nameLocalizations: client.i18n.getAllMessages(`commands.slash.${name}.name`),
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -10,43 +10,27 @@ const pad = require('pad');
|
||||
|
||||
module.exports = class TranscriptSlashCommand extends SlashCommand {
|
||||
constructor(client, options) {
|
||||
const descriptionLocalizations = {};
|
||||
client.i18n.locales.forEach(l => (descriptionLocalizations[l] = client.i18n.getMessage(l, 'commands.slash.transcript.description')));
|
||||
|
||||
const nameLocalizations = {};
|
||||
client.i18n.locales.forEach(l => (nameLocalizations[l] = client.i18n.getMessage(l, 'commands.slash.transcript.name')));
|
||||
|
||||
let opts = [
|
||||
{
|
||||
autocomplete: true,
|
||||
name: 'ticket',
|
||||
required: true,
|
||||
type: ApplicationCommandOptionType.String,
|
||||
},
|
||||
];
|
||||
opts = opts.map(o => {
|
||||
const descriptionLocalizations = {};
|
||||
client.i18n.locales.forEach(l => (descriptionLocalizations[l] = client.i18n.getMessage(l, `commands.slash.transcript.options.${o.name}.description`)));
|
||||
|
||||
const nameLocalizations = {};
|
||||
client.i18n.locales.forEach(l => (nameLocalizations[l] = client.i18n.getMessage(l, `commands.slash.transcript.options.${o.name}.name`)));
|
||||
|
||||
return {
|
||||
...o,
|
||||
description: descriptionLocalizations['en-GB'],
|
||||
descriptionLocalizations,
|
||||
nameLocalizations: nameLocalizations,
|
||||
};
|
||||
});
|
||||
|
||||
const name = 'transcript';
|
||||
super(client, {
|
||||
...options,
|
||||
description: descriptionLocalizations['en-GB'],
|
||||
descriptionLocalizations,
|
||||
description: client.i18n.getMessage(null, `commands.slash.${name}.description`),
|
||||
descriptionLocalizations: client.i18n.getAllMessages(`commands.slash.${name}.description`),
|
||||
dmPermission: false,
|
||||
name: nameLocalizations['en-GB'],
|
||||
nameLocalizations,
|
||||
options: opts,
|
||||
name,
|
||||
nameLocalizations: client.i18n.getAllMessages(`commands.slash.${name}.name`),
|
||||
options: [
|
||||
{
|
||||
autocomplete: true,
|
||||
name: 'ticket',
|
||||
required: true,
|
||||
type: ApplicationCommandOptionType.String,
|
||||
},
|
||||
].map(option => {
|
||||
option.descriptionLocalizations = client.i18n.getAllMessages(`commands.slash.${name}.options.${option.name}.description`);
|
||||
option.description = option.descriptionLocalizations['en-GB'];
|
||||
option.nameLocalizations = client.i18n.getAllMessages(`commands.slash.${name}.options.${option.name}.name`);
|
||||
return option;
|
||||
}),
|
||||
});
|
||||
|
||||
Mustache.escape = text => text; // don't HTML-escape
|
||||
|
@ -3,42 +3,26 @@ const { ApplicationCommandOptionType } = require('discord.js');
|
||||
|
||||
module.exports = class TransferSlashCommand extends SlashCommand {
|
||||
constructor(client, options) {
|
||||
const descriptionLocalizations = {};
|
||||
client.i18n.locales.forEach(l => (descriptionLocalizations[l] = client.i18n.getMessage(l, 'commands.slash.transfer.description')));
|
||||
|
||||
const nameLocalizations = {};
|
||||
client.i18n.locales.forEach(l => (nameLocalizations[l] = client.i18n.getMessage(l, 'commands.slash.transfer.name')));
|
||||
|
||||
let opts = [
|
||||
{
|
||||
name: 'member',
|
||||
required: true,
|
||||
type: ApplicationCommandOptionType.User,
|
||||
},
|
||||
];
|
||||
opts = opts.map(o => {
|
||||
const descriptionLocalizations = {};
|
||||
client.i18n.locales.forEach(l => (descriptionLocalizations[l] = client.i18n.getMessage(l, `commands.slash.transfer.options.${o.name}.description`)));
|
||||
|
||||
const nameLocalizations = {};
|
||||
client.i18n.locales.forEach(l => (nameLocalizations[l] = client.i18n.getMessage(l, `commands.slash.transfer.options.${o.name}.name`)));
|
||||
|
||||
return {
|
||||
...o,
|
||||
description: descriptionLocalizations['en-GB'],
|
||||
descriptionLocalizations,
|
||||
nameLocalizations: nameLocalizations,
|
||||
};
|
||||
});
|
||||
|
||||
const name = 'transfer';
|
||||
super(client, {
|
||||
...options,
|
||||
description: descriptionLocalizations['en-GB'],
|
||||
descriptionLocalizations,
|
||||
description: client.i18n.getMessage(null, `commands.slash.${name}.description`),
|
||||
descriptionLocalizations: client.i18n.getAllMessages(`commands.slash.${name}.description`),
|
||||
dmPermission: false,
|
||||
name: nameLocalizations['en-GB'],
|
||||
nameLocalizations,
|
||||
options: opts,
|
||||
name,
|
||||
nameLocalizations: client.i18n.getAllMessages(`commands.slash.${name}.name`),
|
||||
options: [
|
||||
{
|
||||
name: 'member',
|
||||
required: true,
|
||||
type: ApplicationCommandOptionType.User,
|
||||
},
|
||||
].map(option => {
|
||||
option.descriptionLocalizations = client.i18n.getAllMessages(`commands.slash.${name}.options.${option.name}.description`);
|
||||
option.description = option.descriptionLocalizations['en-GB'];
|
||||
option.nameLocalizations = client.i18n.getAllMessages(`commands.slash.${name}.options.${option.name}.name`);
|
||||
return option;
|
||||
}),
|
||||
});
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user