From d9ece4becaf23bfd7fe87972fb0cf6de8d6986db Mon Sep 17 00:00:00 2001 From: Isaac Date: Mon, 10 May 2021 23:11:25 +0100 Subject: [PATCH] Start on panel creation --- src/commands/panel.js | 85 ++++++++++++++++++++++++++++++ src/database/models/panel.model.js | 28 ++++++++++ src/locales/en-GB.json | 44 +++++++++++++--- 3 files changed, 151 insertions(+), 6 deletions(-) create mode 100644 src/commands/panel.js create mode 100644 src/database/models/panel.model.js diff --git a/src/commands/panel.js b/src/commands/panel.js new file mode 100644 index 0000000..962d60c --- /dev/null +++ b/src/commands/panel.js @@ -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 + } + } + } + + } +}; \ No newline at end of file diff --git a/src/database/models/panel.model.js b/src/database/models/panel.model.js new file mode 100644 index 0000000..83080ed --- /dev/null +++ b/src/database/models/panel.model.js @@ -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' + }); +}; \ No newline at end of file diff --git a/src/locales/en-GB.json b/src/locales/en-GB.json index 118fd9d..e89eb55 100644 --- a/src/locales/en-GB.json +++ b/src/locales/en-GB.json @@ -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"