Remove slash commands

Not fully tested but working so far
This commit is contained in:
Isaac
2021-03-29 23:34:50 +01:00
parent 82c3175f37
commit 245bba0c10
11 changed files with 104 additions and 350 deletions

View File

@@ -1,5 +1,4 @@
const { MessageEmbed } = require('discord.js');
const { OptionTypes } = require('../modules/commands/helpers');
const Command = require('../modules/commands/command');
module.exports = class NewCommand extends Command {
@@ -9,37 +8,41 @@ module.exports = class NewCommand extends Command {
internal: true,
name: i18n('commands.new.name'),
description: i18n('commands.new.description'),
// slash: false,
options: [
aliases: [
i18n('commands.new.aliases.open'),
i18n('commands.new.aliases.create'),
],
args: [
{
name: i18n('commands.new.options.category.name'),
type: OptionTypes.STRING,
description: i18n('commands.new.options.topic.description'),
name: i18n('commands.new.args.category.name'),
description: i18n('commands.new.args.topic.description'),
required: true,
},
{
name: i18n('commands.new.options.topic.name'),
type: OptionTypes.STRING,
description: i18n('commands.new.options.topic.description'),
name: i18n('commands.new.args.topic.name'),
description: i18n('commands.new.args.topic.description'),
required: false,
}
]
});
}
async execute({ guild, member, channel, args }, interaction) {
async execute(message, args, raw_args) {
let settings = await guild.settings;
let settings = await message.guild.settings;
const i18n = this.client.i18n.get(settings.locale);
await channel.send(
await message.channel.send(
new MessageEmbed()
.setColor(settings.colour)
.setTitle(i18n('bot.version', require('../../package.json').version))
.setDescription(args.topic)
);
// this.client.tickets.create(guild.id, member.id, args.category, args.topic);
this.client.tickets.create(guild.id, member.id, '825861413687787560');
// console.log(this.aliases)
// console.log(args.category)
// console.log(args.topic)
// this.client.tickets.create(message.guild.id, message.member.id, '825861413687787560', args.topic);
}
};

View File

@@ -7,16 +7,15 @@ module.exports = class SettingsCommand extends Command {
const i18n = client.i18n.get(client.config.locale);
super(client, {
internal: true,
slash: false,
name: i18n('commands.settings.name'),
description: i18n('commands.settings.description'),
permissions: ['MANAGE_GUILD']
});
}
async execute({ guild, channel, member }, message) {
async execute(message) {
let settings = await guild.settings;
let settings = await message.guild.settings;
const i18n = this.client.i18n.get(settings.locale);
let attachments = [ ...message.attachments.values() ];
@@ -24,9 +23,10 @@ module.exports = class SettingsCommand extends Command {
if (attachments.length >= 1) {
// load settings from json
this.client.log.info(`Downloading settings for "${guild.name}"`);
this.client.log.info(`Downloading settings for "${message.guild.name}"`);
let data = await (await fetch(attachments[0].url)).json();
settings.colour = data.colour;
settings.command_prefix = data.command_prefix;
settings.error_colour = data.error_colour;
settings.locale = data.locale;
settings.log_messages = data.log_messages;
@@ -51,7 +51,7 @@ module.exports = class SettingsCommand extends Command {
let cat_channel = await this.client.channels.fetch(c.id);
if (cat_channel.name !== c.name)
await cat_channel.setName(c.name, `Tickets category updated by ${member.user.tag}`);
await cat_channel.setName(c.name, `Tickets category updated by ${message.member.user.tag}`);
for (let r of c.roles) {
await cat_channel.updateOverwrite(r, {
@@ -59,21 +59,21 @@ module.exports = class SettingsCommand extends Command {
READ_MESSAGE_HISTORY: true,
SEND_MESSAGES: true,
ATTACH_FILES: true
}, `Tickets category updated by ${member.user.tag}`);
}, `Tickets category updated by ${message.member.user.tag}`);
}
} else {
// create a new category
const allowed_permissions = ['VIEW_CHANNEL', 'READ_MESSAGE_HISTORY', 'SEND_MESSAGES', 'EMBED_LINKS', 'ATTACH_FILES'];
let cat_channel = await guild.channels.create(c.name, {
let cat_channel = await message.guild.channels.create(c.name, {
type: 'category',
reason: `Tickets category created by ${member.user.tag}`,
reason: `Tickets category created by ${message.member.user.tag}`,
position: 0,
permissionOverwrites: [
...[
{
id: guild.roles.everyone,
id: message.guild.roles.everyone,
deny: ['VIEW_CHANNEL']
},
{
@@ -94,14 +94,14 @@ module.exports = class SettingsCommand extends Command {
max_per_member: c.max_per_member,
name: c.name,
name_format: c.name_format,
guild: guild.id,
guild: message.guild.id,
roles: c.roles,
});
}
}
this.client.log.success(`Updated guild settings for "${guild.name}"`);
channel.send(i18n('commands.settings.response.updated'));
this.client.log.success(`Updated guild settings for "${message.guild.name}"`);
message.channel.send(i18n('commands.settings.response.updated'));
} else {
@@ -109,6 +109,7 @@ module.exports = class SettingsCommand extends Command {
let data = {
categories: [],
colour: settings.colour,
command_prefix: settings.command_prefix,
error_colour: settings.error_colour,
locale: settings.locale,
log_messages: settings.log_messages,
@@ -117,7 +118,7 @@ module.exports = class SettingsCommand extends Command {
let categories = await this.client.db.models.Category.findAll({
where: {
guild: guild.id
guild: message.guild.id
}
});
@@ -133,10 +134,10 @@ module.exports = class SettingsCommand extends Command {
let attachment = new MessageAttachment(
Buffer.from(JSON.stringify(data, null, 2)),
`Settings for ${guild.name}.json`
`Settings for ${message.guild.name}.json`
);
channel.send({
message.channel.send({
files: [attachment]
});