This commit is contained in:
Isaac 2022-10-10 15:44:13 +01:00
parent 35ad490ba6
commit 6f535e7149
No known key found for this signature in database
GPG Key ID: 0DE40AE37BBA5C33
2 changed files with 149 additions and 27 deletions

View File

@ -0,0 +1,84 @@
const { SlashCommand } = require('@eartharoid/dbf');
const { isStaff } = require('../../lib/users');
const ExtendedEmbedBuilder = require('../../lib/embed');
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')));
super(client, {
...options,
description: descriptionLocalizations['en-GB'],
descriptionLocalizations,
dmPermission: false,
name: nameLocalizations['en-GB'],
nameLocalizations,
});
}
/**
* @param {import("discord.js").ChatInputCommandInteraction} interaction
*/
async run(interaction) {
/** @type {import("client")} */
const client = this.client;
const staff = await isStaff(interaction.guild, interaction.member.id);
const settings = await client.prisma.guild.findUnique({ where: { id: interaction.guild.id } });
const getMessage = client.i18n.getLocale(settings.locale);
await interaction.deferReply({ ephemeral: true });
const commands = (await client.application.commands.fetch())
.filter(c => c.type === 1)
.map(c => `> </${c.name}:${c.id}>: ${c.description}`)
.join('\n');
const ticket = client.application.commands.cache.find(c => c.name === 'new');
const fields = [
{
name: getMessage('commands.slash.help.response.commands'),
value: commands,
},
];
if (staff) {
fields.unshift(
{
inline: true,
name: getMessage('commands.slash.help.response.links.links'),
value: [
['commands', 'https://discordtickets.app/features/commands'],
['docs', 'https://discordtickets.app'],
['feedback', 'https://lnk.earth/dsctickets-feedback'],
['support', 'https://lnk.earth/discord'],
]
.map(([l, url]) => `> [${getMessage('commands.slash.help.response.links.' + l)}](${url})`)
.join('\n'),
},
{
inline: true,
name: getMessage('commands.slash.help.response.settings'),
value: '> ' + process.env.HTTP_EXTERNAL + '/settings',
},
);
}
interaction.editReply({
embeds: [
new ExtendedEmbedBuilder({
iconURL: interaction.guild.iconURL(),
text: settings.footer,
})
.setColor(settings.primaryColour)
.setTitle(getMessage('commands.slash.help.title'))
.setDescription(staff
? `**Discord Tickets v${version} by eartharoid.**`
: getMessage('commands.slash.help.response.description', { command: `</${ticket.name}:${ticket.id}>` }))
.setFields(fields),
],
});
}
};

View File

@ -1,4 +1,7 @@
buttons: buttons:
cancel:
emoji: 🚫
text: Cancel
claim: claim:
emoji: 🙌 emoji: 🙌
text: Claim text: Claim
@ -32,8 +35,8 @@ commands:
description: You can only pin messages in tickets. description: You can only pin messages in tickets.
title: ❌ This isn't a ticket channel title: ❌ This isn't a ticket channel
pinned: pinned:
description: The message has been pinned. description: The message has been pinned.
title: ✅ Pinned message title: ✅ Pinned message
slash: slash:
add: add:
description: Add a member to a ticket description: Add a member to a ticket
@ -49,7 +52,10 @@ commands:
description: Claim a ticket description: Claim a ticket
name: claim name: claim
close: close:
description: Close a ticket description: Request a ticket to be closed
invalid_time:
description: "`{input}` is not a valid time format."
title: ❌ Invalid
name: close name: close
options: options:
reason: reason:
@ -58,12 +64,24 @@ commands:
ticket: ticket:
description: The ticket to close description: The ticket to close
name: ticket name: ticket
time:
description: Close all tickets that have been inactive for the specific time
name: time
force-close: force-close:
confirm_multiple:
description: >
You are about to close **{count}** tickets that have been inactive for
more than `{time}`:
{tickets}
title: ❓ Are you sure?
description: Forcibly close a ticket description: Forcibly close a ticket
name: force-close name: force-close
no_tickets:
description: >-
There are no open tickets that have been inactive for more than
`{time}`.
title: ❌ No tickets
not_staff:
description: Only staff members can force-close tickets.
title: ❌ Error
options: options:
reason: reason:
description: The reason for closing the ticket(s) description: The reason for closing the ticket(s)
@ -72,8 +90,22 @@ commands:
description: The ticket to close description: The ticket to close
name: ticket name: ticket
time: time:
description: Close all tickets that have been inactive for the specific time description: Close all tickets that have been inactive for the specified time
name: time name: time
help:
description: Show the help menu
name: help
response:
commands: Commands
description: "**Use {command} to create a ticket and get support.**"
links:
commands: Full command list
docs: Documentation
feedback: Feedback
links: Useful links
support: Support
settings: Bot settings
title: Help
new: new:
description: Create a new ticket description: Create a new ticket
name: new name: new
@ -88,8 +120,8 @@ commands:
priority: priority:
choices: choices:
HIGH: 🔴 High HIGH: 🔴 High
MEDIUM: 🟠 Medium
LOW: 🟢 Low LOW: 🟢 Low
MEDIUM: 🟠 Medium
description: The priority of the ticket description: The priority of the ticket
name: priority name: priority
success: success:
@ -118,9 +150,6 @@ commands:
tag: tag:
description: The name of the tag to use description: The name of the tag to use
name: tag name: tag
topic:
description: Change the topic of a ticket
name: topic
tickets: tickets:
description: List your own or someone else's tickets description: List your own or someone else's tickets
name: tickets name: tickets
@ -128,6 +157,9 @@ commands:
member: member:
description: The member to list the tickets of description: The member to list the tickets of
name: member name: member
topic:
description: Change the topic of a ticket
name: topic
transcript: transcript:
description: Get the transcript of a ticket description: Get the transcript of a ticket
name: transcript name: transcript
@ -147,12 +179,12 @@ commands:
name: Create a ticket for user name: Create a ticket for user
dm: dm:
confirm_open: confirm_open:
title: 'Do you want to open a ticket with the following topic?' title: Do you want to open a ticket with the following topic?
log: log:
admin: admin:
changes: Changes changes: Changes
description: description:
joined: '{user} {verb} {targetType}' joined: "{user} {verb} {targetType}"
target: target:
category: a category category: a category
panel: a panel panel: a panel
@ -160,7 +192,7 @@ log:
settings: the settings settings: the settings
tag: a tag tag: a tag
title: title:
joined: '{targetType} {verb}' joined: "{targetType} {verb}"
target: target:
category: Category category: Category
panel: Panel panel: Panel
@ -172,13 +204,13 @@ log:
delete: deleted delete: deleted
update: updated update: updated
ticket: ticket:
description: '{user} {verb} a ticket' description: "{user} {verb} a ticket"
ticket: Ticket ticket: Ticket
title: Ticket {verb} title: Ticket {verb}
verb: verb:
create: created
claim: claimed claim: claimed
close: closed close: closed
create: created
unclaim: released unclaim: released
update: updated update: updated
menus: menus:
@ -203,6 +235,10 @@ misc:
fields: fields:
identifier: Identifier identifier: Identifier
title: ⚠️ Something's wrong title: ⚠️ Something's wrong
expired:
description: You didn't respond in time. Please try again.
title: ⏰ Expired
expires_in: Expires in {time}
member_limit: member_limit:
description: description:
- Please use your existing ticket or close it before creating another. - Please use your existing ticket or close it before creating another.
@ -213,14 +249,16 @@ misc:
- ❌ You already have a ticket - ❌ You already have a ticket
- ❌ You already have %d open tickets - ❌ You already have %d open tickets
missing_roles: missing_roles:
description: You do not have the roles required to be able to create a ticket in this category. description: >-
You do not have the roles required to be able to create a ticket in this
category.
title: ❌ Insufficient roles title: ❌ Insufficient roles
no_categories: no_categories:
description: No ticket categories have been configured. description: No ticket categories have been configured.
title: ❌ There are no ticket categories title: ❌ There are no ticket categories
not_ticket: not_ticket:
description: You can only use this command in tickets. description: You can only use this command in tickets.
title: ❌ This isn't a ticket channel title: ❌ This isn't a ticket channel
ratelimited: ratelimited:
description: Try again in a few seconds. description: Try again in a few seconds.
title: 🐢 Please slow down title: 🐢 Please slow down
@ -234,11 +272,11 @@ modals:
label: Topic label: Topic
placeholder: What is this ticket about? placeholder: What is this ticket about?
ticket: ticket:
created:
description: 'Your ticket channel has been created: {channel}.'
title: ✅ Ticket created
answers: answers:
no_value: '*No response*' no_value: "*No response*"
created:
description: "Your ticket channel has been created: {channel}."
title: ✅ Ticket created
edited: edited:
description: Your changes have been saved. description: Your changes have been saved.
title: ✅ Ticket updated title: ✅ Ticket updated
@ -249,10 +287,10 @@ ticket:
fields: fields:
topic: Topic topic: Topic
references_message: references_message:
description: 'References [a message]({url}) sent {timestamp} by {author}.' description: References [a message]({url}) sent {timestamp} by {author}.
title: Reference title: Reference
references_ticket: references_ticket:
description: 'This ticket is related to a previous ticket:' description: "This ticket is related to a previous ticket:"
fields: fields:
date: Created at date: Created at
number: Number number: Number