2019-05-04 01:42:29 +03:00
|
|
|
const Discord = require('discord.js');
|
2019-05-04 01:54:28 +03:00
|
|
|
const { version } = require('../package.json');
|
2019-05-04 02:01:33 +03:00
|
|
|
const config = require('../config.json');
|
2019-05-06 19:18:43 +03:00
|
|
|
const log = require(`leekslazylogger`);
|
2019-05-04 00:09:48 +03:00
|
|
|
module.exports = {
|
2019-05-04 01:54:28 +03:00
|
|
|
name: 'help',
|
|
|
|
description: 'Displays help menu',
|
|
|
|
usage: '[command]',
|
|
|
|
aliases: ['command', 'commands'],
|
2019-05-04 14:20:26 +03:00
|
|
|
example: 'help new',
|
2019-05-04 01:54:28 +03:00
|
|
|
args: false,
|
2019-05-04 02:01:33 +03:00
|
|
|
cooldown: config.cooldown,
|
2019-05-04 18:09:05 +03:00
|
|
|
guildOnly: true,
|
2019-05-04 02:01:33 +03:00
|
|
|
execute(message, args) {
|
2019-05-04 01:54:28 +03:00
|
|
|
const client = message.client;
|
2019-05-04 00:09:48 +03:00
|
|
|
// command starts here
|
|
|
|
message.delete();
|
2019-05-04 16:29:49 +03:00
|
|
|
|
|
|
|
const data = [];
|
|
|
|
const { commands } = message.client;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2019-05-04 01:54:28 +03:00
|
|
|
if (config.useEmbeds) {
|
2019-05-04 16:29:49 +03:00
|
|
|
if (!args.length) {
|
|
|
|
data.push('__**Commands**__');
|
|
|
|
data.push(commands.map(command => `**${config.prefix}${command.name}** : \`${command.description}\``).join('\n'));
|
2019-09-09 20:16:50 +03:00
|
|
|
data.push(`\nType \`${config.prefix}help [command]\` for more information about a specific command.`);
|
2019-05-04 16:29:49 +03:00
|
|
|
|
|
|
|
const embed = new Discord.RichEmbed()
|
2019-05-05 20:42:56 +03:00
|
|
|
.setTitle("Commands")
|
2019-05-04 16:29:49 +03:00
|
|
|
.setColor(config.colour)
|
2019-09-09 20:16:50 +03:00
|
|
|
.setDescription(`\nType \`${config.prefix}help [command]\` for more information about a specific command.`)
|
2019-05-04 16:29:49 +03:00
|
|
|
// .addField("...", `...`, true)
|
|
|
|
// .addField("...", `...`, true)
|
2019-05-05 20:42:56 +03:00
|
|
|
.setFooter(`DiscordTickets by Eartharoid`);
|
2019-05-04 16:29:49 +03:00
|
|
|
|
|
|
|
var cmds = [];
|
2019-05-04 22:16:48 +03:00
|
|
|
cmds.push(commands.map(command => embed.addField(`${config.prefix}${command.name}`, `\`${command.description}\``)));
|
2019-05-04 16:29:49 +03:00
|
|
|
message.channel.send(embed)
|
|
|
|
.then(() => {
|
|
|
|
if (message.channel.type === 'dm') return;
|
|
|
|
// message.channel.send(`A list of commands has been sent to you.`);
|
|
|
|
})
|
|
|
|
.catch(error => {
|
|
|
|
// console.error(`Could not send help DM to ${message.author.tag}.\n`, error);
|
2019-05-05 16:31:21 +03:00
|
|
|
log.warn(`Could not DM help menu to ${message.author.tag}, sending to server channel instead`);
|
2019-05-04 16:29:49 +03:00
|
|
|
message.channel.send(`:x: **Sorry!** There was an error whilst sending the help menu via DMs.`)
|
|
|
|
message.channel.send(data, { split: true })
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
const name = args[0].toLowerCase();
|
|
|
|
const command = commands.get(name) || commands.find(c => c.aliases && c.aliases.includes(name));
|
|
|
|
|
|
|
|
if (!command) {
|
|
|
|
const notCmd = new Discord.RichEmbed()
|
|
|
|
.setColor("#E74C3C")
|
|
|
|
.setDescription(`:x: **Invalid command name** (\`${config.prefix}help\`)`)
|
|
|
|
return message.channel.send(notCmd)
|
|
|
|
}
|
|
|
|
|
|
|
|
const cmd = new Discord.RichEmbed()
|
|
|
|
.setColor(config.colour)
|
2019-05-04 18:09:05 +03:00
|
|
|
.addField(`Command`,`\`${command.name}\``, true)
|
2019-05-05 20:42:56 +03:00
|
|
|
.setFooter(`DiscordTickets by Eartharoid`);
|
2019-05-04 16:29:49 +03:00
|
|
|
|
|
|
|
if (command.aliases) cmd.addField("Aliases", `\`${command.aliases.join(', ')}\``, true);
|
2019-05-05 22:19:29 +03:00
|
|
|
if (command.description) cmd.addField("Description", `\`${command.description}\``, false);
|
|
|
|
if (command.usage) cmd.addField("Usage", `\`${config.prefix}${command.name} ${command.usage}\``, false)
|
|
|
|
if (command.example) cmd.addField("Example", `\`${config.prefix}${command.example}\``, false);
|
2019-05-04 16:29:49 +03:00
|
|
|
message.channel.send(cmd)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-05-04 00:09:48 +03:00
|
|
|
} else {
|
2019-05-04 16:29:49 +03:00
|
|
|
// message.channel.send(`**Prefix =** \`${config.prefix}\`\n**Bot Version =** \`${version}\``)
|
|
|
|
|
|
|
|
if (!args.length) {
|
|
|
|
data.push('__**Commands**__');
|
|
|
|
data.push(commands.map(command => `**${config.prefix}${command.name}** : \`${command.description}\``).join('\n'));
|
2019-09-09 20:16:50 +03:00
|
|
|
data.push(`\nType \`${config.prefix}help [command]\` for more information about a specific command.`);
|
2019-05-04 16:29:49 +03:00
|
|
|
|
|
|
|
return message.author.send(data, { split: true })
|
|
|
|
.then(() => {
|
|
|
|
if (message.channel.type === 'dm') return;
|
|
|
|
// message.channel.send(`A list of commands has been sent to you.`);
|
|
|
|
})
|
|
|
|
.catch(error => {
|
|
|
|
// console.error(`Could not send help DM to ${message.author.tag}.\n`, error);
|
2019-05-05 16:31:21 +03:00
|
|
|
log.warn(`Could not DM help menu to ${message.author.tag}, sending to server channel instead`);
|
2019-05-04 16:29:49 +03:00
|
|
|
message.channel.send(`:x: **Sorry!** There was an error whilst sending the help menu via DMs.`)
|
|
|
|
message.channel.send(data, { split: true })
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
const name = args[0].toLowerCase();
|
|
|
|
const command = commands.get(name) || commands.find(c => c.aliases && c.aliases.includes(name));
|
|
|
|
|
|
|
|
if (!command) {
|
|
|
|
return message.reply(':x: **Invalid command**');
|
|
|
|
}
|
|
|
|
|
|
|
|
data.push(`**Command:** \`${command.name}\``);
|
|
|
|
|
|
|
|
if (command.aliases) data.push(`**Aliases:** \`${command.aliases.join(', ')}\``);
|
|
|
|
if (command.description) data.push(`**Description:** \`${command.description}\``);
|
|
|
|
if (command.usage) data.push(`**Usage:** \`${config.prefix}${command.name} ${command.usage}\``);
|
|
|
|
if (command.example) data.push(`**Example:** \`${command.example}\``);
|
|
|
|
|
|
|
|
data.push(`**Cooldown:** \`${command.cooldown || 3} second(s)\``);
|
|
|
|
|
|
|
|
message.channel.send(data, { split: true });
|
2019-05-04 00:09:48 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-05-05 20:42:56 +03:00
|
|
|
|
2019-05-04 00:09:48 +03:00
|
|
|
// command ends here
|
2019-05-04 01:54:28 +03:00
|
|
|
},
|
2019-05-04 00:09:48 +03:00
|
|
|
};
|