mirror of
https://github.com/Hessenuk/DiscordTickets.git
synced 2024-12-23 08:13:09 +02:00
Start on panel creation
This commit is contained in:
parent
de93d586fe
commit
d9ece4beca
85
src/commands/panel.js
Normal file
85
src/commands/panel.js
Normal file
@ -0,0 +1,85 @@
|
||||
const Command = require('../modules/commands/command');
|
||||
const { MessageEmbed } = require('discord.js');
|
||||
|
||||
module.exports = class PanelCommand extends Command {
|
||||
constructor(client) {
|
||||
const i18n = client.i18n.getLocale(client.config.locale);
|
||||
super(client, {
|
||||
internal: true,
|
||||
name: i18n('commands.panel.name'),
|
||||
description: i18n('commands.panel.description'),
|
||||
aliases: [],
|
||||
process_args: true,
|
||||
args: [
|
||||
{
|
||||
name: i18n('commands.panel.args.title.name'),
|
||||
description: i18n('commands.panel.args.title.description'),
|
||||
example: i18n('commands.panel.args.title.example'),
|
||||
required: false,
|
||||
// for arg parsing
|
||||
alias: i18n('commands.panel.args.title.alias'),
|
||||
type: String
|
||||
},
|
||||
{
|
||||
name: i18n('commands.panel.args.description.name'),
|
||||
description: i18n('commands.panel.args.description.description'),
|
||||
example: i18n('commands.panel.args.description.example'),
|
||||
required: true,
|
||||
// for arg parsing
|
||||
alias: i18n('commands.panel.args.description.alias'),
|
||||
type: String
|
||||
},
|
||||
{
|
||||
name: i18n('commands.panel.args.emoji.name'),
|
||||
description: i18n('commands.panel.args.emoji.description'),
|
||||
example: i18n('commands.panel.args.emoji.example'),
|
||||
required: false,
|
||||
// for arg parsing
|
||||
alias: i18n('commands.panel.args.emoji.alias'),
|
||||
type: String,
|
||||
multiple: true,
|
||||
},
|
||||
{
|
||||
name: i18n('commands.panel.args.category.name'),
|
||||
description: i18n('commands.panel.args.category.description'),
|
||||
example: i18n('commands.panel.args.category.example'),
|
||||
required: true,
|
||||
// for arg parsing
|
||||
alias: i18n('commands.panel.args.category.alias'),
|
||||
type: String,
|
||||
multiple: true,
|
||||
}
|
||||
],
|
||||
permissions: ['MANAGE_GUILD']
|
||||
});
|
||||
}
|
||||
|
||||
async execute(message, args) {
|
||||
|
||||
const arg_title = this.args[0].name;
|
||||
const arg_description = this.args[1].name;
|
||||
const arg_emoji = this.args[2].name;
|
||||
const arg_category = this.args[3].name;
|
||||
|
||||
let settings = await message.guild.settings;
|
||||
const i18n = this.client.i18n.getLocale(settings.locale);
|
||||
|
||||
console.log(args)
|
||||
message.channel.send(Object.keys(args).map(arg => `${arg}: \`${args[arg]}\``).join('\n'))
|
||||
|
||||
if (!args[arg_emoji]) {
|
||||
// reaction-less panel
|
||||
} else {
|
||||
if (!args[arg_category] || args[arg_category].length !== args[arg_emoji.length]) {
|
||||
// send error
|
||||
} else {
|
||||
if (args[arg_emoji].length === 1) {
|
||||
// single category
|
||||
} else {
|
||||
// multi category
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
};
|
28
src/database/models/panel.model.js
Normal file
28
src/database/models/panel.model.js
Normal file
@ -0,0 +1,28 @@
|
||||
const { DataTypes } = require('sequelize');
|
||||
module.exports = (client, sequelize) => {
|
||||
const { DB_TABLE_PREFIX } = process.env;
|
||||
sequelize.define('Panel', {
|
||||
categories: {
|
||||
type: DataTypes.JSON,
|
||||
allowNull: false
|
||||
},
|
||||
guild: {
|
||||
type: DataTypes.CHAR(19),
|
||||
allowNull: false,
|
||||
references: {
|
||||
model: DB_TABLE_PREFIX + 'guilds',
|
||||
key: 'id'
|
||||
}
|
||||
},
|
||||
message: {
|
||||
type: DataTypes.CHAR(19),
|
||||
allowNull: false
|
||||
},
|
||||
reactionless: {
|
||||
type: DataTypes.BOOLEAN,
|
||||
defaultValue: false
|
||||
}
|
||||
}, {
|
||||
tableName: DB_TABLE_PREFIX + 'panels'
|
||||
});
|
||||
};
|
@ -23,9 +23,9 @@
|
||||
},
|
||||
"args": {
|
||||
"member_or_role": {
|
||||
"name": "memberOrRole",
|
||||
"description": "A member mention, a role mention, or the ID of a member or role",
|
||||
"example": "@NaughtyMember"
|
||||
"example": "@NaughtyMember",
|
||||
"name": "memberOrRole"
|
||||
}
|
||||
},
|
||||
"description": "Blacklist/unblacklist a member from interacting with the bot",
|
||||
@ -66,9 +66,9 @@
|
||||
},
|
||||
"args": {
|
||||
"ticket": {
|
||||
"name": "ticket",
|
||||
"description": "The number or a channel mention of the ticket to close",
|
||||
"example": "217"
|
||||
"example": "217",
|
||||
"name": "ticket"
|
||||
}
|
||||
},
|
||||
"description": "Close a ticket channel",
|
||||
@ -99,9 +99,9 @@
|
||||
},
|
||||
"args": {
|
||||
"topic": {
|
||||
"name": "topic",
|
||||
"description": "The topic of the ticket",
|
||||
"example": "Problem with billing"
|
||||
"example": "Problem with billing",
|
||||
"name": "topic"
|
||||
}
|
||||
},
|
||||
"description": "Create a new ticket",
|
||||
@ -147,6 +147,38 @@
|
||||
"description": "Please briefly state what this ticket is about in a a few words."
|
||||
}
|
||||
},
|
||||
"panel": {
|
||||
"aliases": {},
|
||||
"args": {
|
||||
"category": {
|
||||
"alias": "c",
|
||||
"description": "A category ID",
|
||||
"example": "451745464954650634",
|
||||
"name": "category"
|
||||
},
|
||||
"description": {
|
||||
"alias": "d",
|
||||
"description": "The description for the panel message",
|
||||
"example": "\"React to this message to open a ticket.\"",
|
||||
"name": "description"
|
||||
},
|
||||
"emoji": {
|
||||
"alias": "e",
|
||||
"description": "A **unicode** emoji character (escaped emoji)",
|
||||
"example": "\\:ticket:",
|
||||
"name": "emoji"
|
||||
},
|
||||
"title": {
|
||||
"alias": "t",
|
||||
"description": "The title for the panel message",
|
||||
"example": "\"Support tickets\"",
|
||||
"name": "title"
|
||||
}
|
||||
},
|
||||
"description": "Create a new ticket panel",
|
||||
"name": "panel",
|
||||
"response": {}
|
||||
},
|
||||
"settings": {
|
||||
"aliases": {
|
||||
"config": "config"
|
||||
|
Loading…
Reference in New Issue
Block a user