Create commands

This commit is contained in:
Isaac 2022-08-02 21:13:32 +01:00
parent e28392352c
commit b4618aac1b
No known key found for this signature in database
GPG Key ID: F4EAABEB0FFCC06A
19 changed files with 743 additions and 19 deletions

View File

@ -9,4 +9,6 @@ PORTAL=http://localhost:3000
SUPER=
https://www.prisma.io/docs/reference/database-reference/supported-databases
https://www.prisma.io/docs/reference/database-reference/supported-databases
![](https://static.eartharoid.me/k/22/08/02185801.png) - for user/create and slash/force-close

View File

@ -34,7 +34,7 @@
"node": ">=18.0"
},
"dependencies": {
"@eartharoid/dbf": "^0.3.1",
"@eartharoid/dbf": "^0.3.2",
"@eartharoid/dtf": "^2.0.1",
"@eartharoid/i18n": "^1.0.4",
"@fastify/cookie": "^6.0.0",

View File

@ -0,0 +1,12 @@
const { Autocompleter } = require('@eartharoid/dbf');
module.exports = class ReferencesCompleter extends Autocompleter {
constructor(client, options) {
super(client, {
...options,
id: 'references',
});
}
async run(value, comamnd, interaction) { }
};

View File

@ -0,0 +1,12 @@
const { Autocompleter } = require('@eartharoid/dbf');
module.exports = class TicketCompleter extends Autocompleter {
constructor(client, options) {
super(client, {
...options,
id: 'ticket',
});
}
async run(value, comamnd, interaction) { }
};

View File

@ -0,0 +1,17 @@
const { MessageCommand } = require('@eartharoid/dbf');
module.exports = class CreateMessageCommand extends MessageCommand {
constructor(client, options) {
const nameLocalizations = {};
client.i18n.locales.forEach(l => (nameLocalizations[l] = client.i18n.getMessage(l, 'commands.message.create.name')));
super(client, {
...options,
dmPermission: false,
name: nameLocalizations['en-GB'],
nameLocalizations,
});
}
async run(interaction) { }
};

View File

@ -0,0 +1,17 @@
const { MessageCommand } = require('@eartharoid/dbf');
module.exports = class PinMessageCommand extends MessageCommand {
constructor(client, options) {
const nameLocalizations = {};
client.i18n.locales.forEach(l => (nameLocalizations[l] = client.i18n.getMessage(l, 'commands.message.pin.name')));
super(client, {
...options,
dmPermission: false,
name: nameLocalizations['en-GB'],
nameLocalizations,
});
}
async run(interaction) { }
};

51
src/commands/slash/add.js Normal file
View File

@ -0,0 +1,51 @@
const { SlashCommand } = require('@eartharoid/dbf');
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,
},
{
name: 'ticket',
required: false,
type: ApplicationCommandOptionType.Channel,
},
];
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,
};
});
super(client, {
...options,
description: descriptionLocalizations['en-GB'],
descriptionLocalizations,
dmPermission: false,
name: nameLocalizations['en-GB'],
nameLocalizations,
options: opts,
});
}
async run(interaction) { }
};

View File

@ -0,0 +1,61 @@
const { SlashCommand } = require('@eartharoid/dbf');
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: 'channel',
required: false,
type: ApplicationCommandOptionType.Channel,
},
{
name: 'number',
required: false,
type: ApplicationCommandOptionType.Integer,
},
{
name: 'reason',
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.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,
};
});
super(client, {
...options,
description: descriptionLocalizations['en-GB'],
descriptionLocalizations,
dmPermission: false,
name: nameLocalizations['en-GB'],
nameLocalizations,
options: opts,
});
}
async run(interaction) { }
};

View File

@ -0,0 +1,61 @@
const { SlashCommand } = require('@eartharoid/dbf');
const { ApplicationCommandOptionType } = require('discord.js');
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 = [
{
name: 'channel',
required: false,
type: ApplicationCommandOptionType.Channel,
},
{
name: 'number',
required: false,
type: ApplicationCommandOptionType.Integer,
},
{
name: 'reason',
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,
};
});
super(client, {
...options,
description: descriptionLocalizations['en-GB'],
descriptionLocalizations,
dmPermission: false,
name: nameLocalizations['en-GB'],
nameLocalizations,
options: opts,
});
}
async run(interaction) { }
};

47
src/commands/slash/new.js Normal file
View File

@ -0,0 +1,47 @@
const { SlashCommand } = require('@eartharoid/dbf');
const { ApplicationCommandOptionType } = require('discord.js');
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.Integer,
},
];
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,
};
});
super(client, {
...options,
description: descriptionLocalizations['en-GB'],
descriptionLocalizations,
dmPermission: false,
name: nameLocalizations['en-GB'],
nameLocalizations,
options: opts,
});
}
async run(interaction) { }
};

View File

@ -0,0 +1,59 @@
const { SlashCommand } = require('@eartharoid/dbf');
const { ApplicationCommandOptionType } = require('discord.js');
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,
};
});
super(client, {
...options,
description: descriptionLocalizations['en-GB'],
descriptionLocalizations,
dmPermission: false,
name: nameLocalizations['en-GB'],
nameLocalizations,
options: opts,
});
}
async run(interaction) { }
};

View File

@ -0,0 +1,51 @@
const { SlashCommand } = require('@eartharoid/dbf');
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,
},
{
name: 'ticket',
required: false,
type: ApplicationCommandOptionType.Channel,
},
];
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,
};
});
super(client, {
...options,
description: descriptionLocalizations['en-GB'],
descriptionLocalizations,
dmPermission: false,
name: nameLocalizations['en-GB'],
nameLocalizations,
options: opts,
});
}
async run(interaction) { }
};

47
src/commands/slash/tag.js Normal file
View File

@ -0,0 +1,47 @@
const { SlashCommand } = require('@eartharoid/dbf');
const { ApplicationCommandOptionType } = require('discord.js');
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.String,
},
];
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,
};
});
super(client, {
...options,
description: descriptionLocalizations['en-GB'],
descriptionLocalizations,
dmPermission: false,
name: nameLocalizations['en-GB'],
nameLocalizations,
options: opts,
});
}
async run(interaction) { }
};

View File

@ -0,0 +1,46 @@
const { SlashCommand } = require('@eartharoid/dbf');
const { ApplicationCommandOptionType } = require('discord.js');
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,
};
});
super(client, {
...options,
description: descriptionLocalizations['en-GB'],
descriptionLocalizations,
dmPermission: false,
name: nameLocalizations['en-GB'],
nameLocalizations,
options: opts,
});
}
async run(interaction) { }
};

View File

@ -0,0 +1,46 @@
const { SlashCommand } = require('@eartharoid/dbf');
const { ApplicationCommandOptionType } = require('discord.js');
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')));
let opts = [
{
name: 'new-topic',
required: true,
type: ApplicationCommandOptionType.String,
},
];
opts = opts.map(o => {
const descriptionLocalizations = {};
client.i18n.locales.forEach(l => (descriptionLocalizations[l] = client.i18n.getMessage(l, `commands.slash.topic.options.${o.name}.description`)));
const nameLocalizations = {};
client.i18n.locales.forEach(l => (nameLocalizations[l] = client.i18n.getMessage(l, `commands.slash.topic.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) { }
};

View File

@ -0,0 +1,47 @@
const { SlashCommand } = require('@eartharoid/dbf');
const { ApplicationCommandOptionType } = require('discord.js');
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.Integer,
},
];
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,
};
});
super(client, {
...options,
description: descriptionLocalizations['en-GB'],
descriptionLocalizations,
dmPermission: false,
name: nameLocalizations['en-GB'],
nameLocalizations,
options: opts,
});
}
async run(interaction) { }
};

View File

@ -0,0 +1,17 @@
const { UserCommand } = require('@eartharoid/dbf');
module.exports = class CreateUserCommand extends UserCommand {
constructor(client, options) {
const nameLocalizations = {};
client.i18n.locales.forEach(l => (nameLocalizations[l] = client.i18n.getMessage(l, 'commands.user.create.name')));
super(client, {
...options,
dmPermission: false,
name: nameLocalizations['en-GB'],
nameLocalizations,
});
}
async run(interaction) { }
};

View File

@ -1,32 +1,142 @@
test: |
line 1
line 2
buttons:
create:
emoji: '🎫'
text: 'Create a ticket'
emoji: 🎫
text: Create a ticket
commands:
message:
create:
name: Create a ticket from message
pin:
name: Pin message
slash:
add:
description: Add a member to a ticket
name: add
options:
member:
description: The member to add to the ticket
name: member
ticket:
description: The ticket to add the member to
name: ticket
close:
description: Close a ticket
name: close
options:
channel:
description: The ticket channel to close
name: channel
number:
description: The number of the ticket to close
name: number
reason:
description: The reason for closing the ticket(s)
name: reason
time:
description: Close all tickets that have been inactive for the specific time
name: time
force-close:
description: Forcibly close a ticket
name: force-close
options:
channel:
description: The ticket channel to close
name: channel
number:
description: The number of the ticket to close
name: number
reason:
description: The reason for closing the ticket(s)
name: reason
time:
description: Close all tickets that have been inactive for the specific time
name: time
new:
description: Create a new ticket
name: new
options:
references:
description: The number of a related ticket
name: references
priority:
description: Set the priority of a ticket
name: priority
options:
priority:
choices:
HIGH: 🔴 High
MEDIUM: 🟠 Medium
LOW: 🟢 Low
description: The priority of the ticket
name: priority
remove:
description: Remove a member from a ticket
name: remove
options:
member:
description: The member to remove from the ticket
name: member
ticket:
description: The ticket to remove the member from
name: ticket
tag:
description: Use a tag
name: tag
options:
tag:
description: The name of the tag to use
name: tag
topic:
description: Change the topic of a ticket
name: topic
options:
new-topic:
description: The new topic of the ticket
name: new-topic
tickets:
description: List your own or someone else's tickets
name: tickets
options:
member:
description: The member to list the tickets of
name: member
transcript:
description: Get the transcript of a ticket
name: transcript
options:
ticket:
description: The number of the ticket to get the transcript of
name: ticket
user:
create:
name: Create a ticket for user
log:
admin:
changes: 'Changes'
changes: Changes
description:
joined: '{user} {verb} {targetType}'
target:
category: 'a category'
panel: 'a panel'
question: 'a question'
settings: 'the settings'
tag: 'a tag'
category: a category
panel: a panel
question: a question
settings: the settings
tag: a tag
title:
joined: '{targetType} {verb}'
target:
category: 'Category'
panel: 'Panel'
question: 'Question'
settings: 'Settings'
tag: 'Tag'
category: Category
panel: Panel
question: Question
settings: Settings
tag: Tag
verb:
create: 'created'
delete: 'deleted'
update: 'updated'
create: created
delete: deleted
update: updated
tickets:
menus:
create:
placeholder: 'Select a ticket category'
placeholder: Select a ticket category

View File

@ -0,0 +1,21 @@
const { Listener } = require('@eartharoid/dbf');
module.exports = class extends Listener {
constructor(client, options) {
super(client, {
...options,
emitter: client.commands,
event: 'componentLoad',
});
}
run(command) {
const types = {
1: 'slash',
2: 'user',
3: 'message',
};
this.client.log.info.commands(`Loaded "${command.name}" ${types[command.type]} command`);
return true;
}
};