-
Notifications
You must be signed in to change notification settings - Fork 28
/
help.js
77 lines (66 loc) · 4.61 KB
/
help.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
const { commands } = require("../config");;
const { MessageEmbed } = require('discord.js');
const fs = require('fs');
module.exports.config = {
name: "help", //Name of command - RENAME THE FILE TOO!!!
description: "Sends the command list menu", //Description of command - you can change it :)
aliases: commands.help, //Command's aliases - set them in config.js
enable: true //Enable this command? - true or false (boolean)
};
module.exports.run = async (bot, message, args) => {
const { server, config, text } = bot;
let icon = server.icon ? server.icon : message.guild.iconURL();
if (!args[0]) {
let commands = [],
lines = [];
commands = fs.readdirSync(`./commands`).filter(file => file.endsWith('.js'));
for (const commandFile of commands) {
const command = bot.commands.get(commandFile.split(".js")[0]);
command.config.description = command.config.description ? command.config.description : false;
if (commands.length > 0) lines.push(`> \`${bot.prefix}${command.config.name ? command.config.name : commandFile.split(".js")[0]}\`` + (command.config.description ? ` - ${command.config.description}` : ""));
}
if (!text.help.title || !text.help.description) {
const helpEmbed = new MessageEmbed()
.setAuthor({ name: config.server.name ? config.server.name : message.guild.name, iconURL: icon })
.setTitle(config.server.name ? config.server.name : message.guild.name + " bot commands:")
.setDescription(`> **Prefix:** \`${bot.prefix}\`\n\n> **Commands:**\n` + lines.join("\n"))
.setColor(config.embeds.color);
message.channel.send({ embeds: [helpEmbed] });
} else {
text.help.title = text.help.title.replaceAll('{serverIp}', server.ip);
text.help.title = text.help.title.replaceAll('{serverPort}', server.port);
text.help.title = text.help.title.replaceAll('{serverName}', config.server.name ? config.server.name : message.guild.name);
text.help.title = text.help.title.replaceAll('{voteLink}', config.server.vote);
text.help.title = text.help.title.replaceAll('{serverType}', config.server.type.charAt(0).toUpperCase() + config.server.type.slice(1));
text.help.title = text.help.title.replaceAll('{prefix}', config.bot.prefix);
text.help.title = text.help.title.replaceAll('{commands}', "\n" + lines.join("\n"));
text.help.description = text.help.description.replaceAll('{serverIp}', server.ip);
text.help.description = text.help.description.replaceAll('{serverPort}', server.port);
text.help.description = text.help.description.replaceAll('{serverName}', config.server.name ? config.server.name : message.guild.name);
text.help.description = text.help.description.replaceAll('{voteLink}', config.server.vote);
text.help.description = text.help.description.replaceAll('{serverType}', config.server.type.charAt(0).toUpperCase() + config.server.type.slice(1));
text.help.description = text.help.description.replaceAll('{prefix}', config.bot.prefix);
text.help.description = text.help.description.replaceAll('{commands}', "\n" + lines.join("\n"));
const helpEmbed = new MessageEmbed()
.setAuthor({ name: config.server.name ? config.server.name : message.guild.name, iconURL: icon })
.setTitle(text.help.title)
.setDescription(text.help.description)
.setColor(config.embeds.color);
message.channel.send({ embeds: [helpEmbed] });
}
return;
}
if (bot.commands.has(args[0].toLocaleLowerCase()) || bot.aliases.has(args[0].toLocaleLowerCase())) {
commandName = bot.commands.has(args[0].toLocaleLowerCase()) ? args[0].toLocaleLowerCase() : bot.aliases.get(args[0].toLocaleLowerCase());
let command = bot.commands.get(commandName);
const helpEmbed = new MessageEmbed()
.setAuthor({ name: config.server.name ? config.server.name : message.guild.name, iconURL: icon })
.setTitle(`${commandName.charAt(0).toUpperCase() + commandName.slice(1)} Command:`)
.setDescription(`
> **Description:** ${!!command.config.description ? command.config.description : "Without description"}
> **Aliases:** ${!!command.config.aliases ? "`" + bot.prefix + command.config.aliases.join(`\`, \`${bot.prefix}`) + "`" : "No aliases"}
`)
.setColor(config.embeds.color);
return message.channel.send({ embeds: [helpEmbed] });
}
};