From 9b0a1fe50fd9fab69753d1508dd8213463209b1e Mon Sep 17 00:00:00 2001 From: Isaac Date: Sun, 16 Oct 2022 14:11:40 +0100 Subject: [PATCH] Add new `/transfer` (ownership) command --- src/commands/slash/transfer.js | 46 ++++++++++++++++++++++++++++++++++ src/i18n/en-GB.yml | 25 +++++++++++------- 2 files changed, 62 insertions(+), 9 deletions(-) create mode 100644 src/commands/slash/transfer.js diff --git a/src/commands/slash/transfer.js b/src/commands/slash/transfer.js new file mode 100644 index 0000000..5584c6f --- /dev/null +++ b/src/commands/slash/transfer.js @@ -0,0 +1,46 @@ +const { SlashCommand } = require('@eartharoid/dbf'); +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, + }; + }); + + super(client, { + ...options, + description: descriptionLocalizations['en-GB'], + descriptionLocalizations, + dmPermission: false, + name: nameLocalizations['en-GB'], + nameLocalizations, + options: opts, + }); + } + + async run(interaction) {} +}; diff --git a/src/i18n/en-GB.yml b/src/i18n/en-GB.yml index 937c530..a17d9a4 100644 --- a/src/i18n/en-GB.yml +++ b/src/i18n/en-GB.yml @@ -106,6 +106,13 @@ commands: support: Support settings: Bot settings title: Help + move: + description: move a ticket to another category + name: move + options: + category: + description: The category to move the ticket to + name: category new: description: Create a new ticket name: new @@ -167,13 +174,13 @@ commands: ticket: description: The number of the ticket to get the transcript of name: ticket - move: - description: move a ticket to another category - name: move + transfer: + description: Transfer ownership of a ticket to another member + name: transfer options: - category: - description: The category to move the ticket to - name: category + member: + description: The member to transfer ownership to + name: member user: create: name: Create a ticket for user @@ -239,6 +246,9 @@ misc: description: You didn't respond in time. Please try again. title: ⏰ Expired expires_in: Expires in {time} + invalid_ticket: + description: Please specify a valid ticket. + title: ❌ Invalid ticket member_limit: description: - Please use your existing ticket or close it before creating another. @@ -259,9 +269,6 @@ misc: not_ticket: description: You can only use this command in tickets. title: ❌ This isn't a ticket channel - invalid_ticket: - description: Please specify a valid ticket. - title: ❌ Invalid ticket ratelimited: description: Try again in a few seconds. title: 🐢 Please slow down