mirror of
https://github.com/Hessenuk/DiscordTickets.git
synced 2024-12-23 00:03:09 +02:00
update
command handler
This commit is contained in:
parent
61310e09b6
commit
239b864bf3
@ -1,13 +1,14 @@
|
|||||||
const Discord = require('discord.js');
|
const Discord = require('discord.js');
|
||||||
const { version } = require('../package.json');
|
const { version } = require('../package.json');
|
||||||
|
const config = require('../config.json');
|
||||||
module.exports = {
|
module.exports = {
|
||||||
name: 'help',
|
name: 'help',
|
||||||
description: 'Displays help menu',
|
description: 'Displays help menu',
|
||||||
usage: '[command]',
|
usage: '[command]',
|
||||||
aliases: ['command', 'commands'],
|
aliases: ['command', 'commands'],
|
||||||
args: false,
|
args: false,
|
||||||
cooldown: 5,
|
cooldown: config.cooldown,
|
||||||
execute(message, args, config, version) {
|
execute(message, args) {
|
||||||
const client = message.client;
|
const client = message.client;
|
||||||
// command starts here
|
// command starts here
|
||||||
message.delete();
|
message.delete();
|
||||||
|
@ -4,7 +4,7 @@ module.exports = {
|
|||||||
usage: '<brief description>',
|
usage: '<brief description>',
|
||||||
aliases: ['ticket'],
|
aliases: ['ticket'],
|
||||||
args: true,
|
args: true,
|
||||||
execute(message, args, config) {
|
execute(message, args) {
|
||||||
// command starts here
|
// command starts here
|
||||||
message.delete();
|
message.delete();
|
||||||
const ticketChannel = "channel";
|
const ticketChannel = "channel";
|
||||||
|
13
index.js
13
index.js
@ -170,8 +170,12 @@ client.on('message', message => {
|
|||||||
const [, matchedPrefix] = message.content.match(prefixRegex);
|
const [, matchedPrefix] = message.content.match(prefixRegex);
|
||||||
const args = message.content.slice(matchedPrefix.length).trim().split(/ +/);
|
const args = message.content.slice(matchedPrefix.length).trim().split(/ +/);
|
||||||
const commandName = args.shift().toLowerCase();
|
const commandName = args.shift().toLowerCase();
|
||||||
if (!client.commands.has(commandName)) return;
|
// if (!client.commands.has(commandName)) return;
|
||||||
const command = client.commands.get(commandName);
|
// const command = client.commands.get(commandName);
|
||||||
|
const command = client.commands.get(commandName)
|
||||||
|
|| client.commands.find(cmd => cmd.aliases && cmd.aliases.includes(commandName));
|
||||||
|
|
||||||
|
if (!command) return;
|
||||||
|
|
||||||
if (command.args && !args.length) {
|
if (command.args && !args.length) {
|
||||||
let reply = `:x: **Arguments were expected but none were provided.**`;
|
let reply = `:x: **Arguments were expected but none were provided.**`;
|
||||||
@ -200,12 +204,13 @@ client.on('message', message => {
|
|||||||
return message.reply(`please wait ${timeLeft.toFixed(1)} more second(s) before reusing the \`${command.name}\` command.`);
|
return message.reply(`please wait ${timeLeft.toFixed(1)} more second(s) before reusing the \`${command.name}\` command.`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
timestamps.set(message.author.id, now);
|
||||||
|
setTimeout(() => timestamps.delete(message.author.id), cooldownAmount);
|
||||||
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// client.commands.get(command).execute(message, args, config);
|
// client.commands.get(command).execute(message, args, config);
|
||||||
command.execute(message, args, config);
|
command.execute(message, args);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
message.channel.send(`:x: **Oof!** An error occured whilst executing that command.\nThe issue has been reported.`);
|
message.channel.send(`:x: **Oof!** An error occured whilst executing that command.\nThe issue has been reported.`);
|
||||||
|
Loading…
Reference in New Issue
Block a user