This commit is contained in:
Eartharoid 2019-05-04 14:29:49 +01:00
parent 91e1e150a9
commit f9a725d81a
2 changed files with 103 additions and 11 deletions

View File

@ -13,18 +13,107 @@ module.exports = {
const client = message.client;
// command starts here
message.delete();
const data = [];
const { commands } = message.client;
if (config.useEmbeds) {
const embed = new Discord.RichEmbed()
.setAuthor(`${client.user.username} / Commands`, client.user.avatarURL)
.setColor(config.colour)
.addField("...", `...`, true)
.addField("...", `...`, true)
.setFooter(`${client.guilds.get(config.guildID).name} : DiscordTickets by Eartharoid`);
message.channel.send({
embed
})
if (!args.length) {
data.push('__**Commands**__');
data.push(commands.map(command => `**${config.prefix}${command.name}** : \`${command.description}\``).join('\n'));
data.push(`\nType\`${config.prefix}help [command]\` for more information about a specific command.`);
const embed = new Discord.RichEmbed()
.setAuthor(`${client.user.username} / Commands`, client.user.avatarURL)
.setColor(config.colour)
.setDescription(`\nType\`${config.prefix}help [command]\` for more information about a specific command.`)
// .addField("...", `...`, true)
// .addField("...", `...`, true)
.setFooter(`${client.guilds.get(config.guildID).name} : DiscordTickets by Eartharoid`);
var cmds = [];
cmds.push(commands.map(command => embed.addField(`${config.prefix}${command.name}`, `\`${command.description}\``, true)));
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);
console.log(leeks.colors.yellow(leeks.styles.bold(`[WARN] Could not DM help menu to ${message.author.tag}, sending to server channel instead`)));
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()
.setAuthor(`${client.user.username}`, client.user.avatarURL)
.setColor("#E74C3C")
.setDescription(`:x: **Invalid command name** (\`${config.prefix}help\`)`)
.setFooter(`${client.guilds.get(config.guildID).name} : DiscordTickets by Eartharoid`);
return message.channel.send(notCmd)
}
const cmd = new Discord.RichEmbed()
.setAuthor(`${client.user.username} / Commands`, client.user.avatarURL)
.setColor(config.colour)
.setFooter(`${client.guilds.get(config.guildID).name} : DiscordTickets by Eartharoid`);
if (command.aliases) cmd.addField("Aliases", `\`${command.aliases.join(', ')}\``, true);
if (command.description) cmd.addField("Description", `\`${command.description}\``, true);
if (command.usage) cmd.addField("Usage", `\`${config.prefix}${command.name} ${command.usage}\``, true)
if (command.example) cmd.addField("Example", `\`${config.prefix}${command.example}\``, true);
message.channel.send(cmd)
}
} else {
message.channel.send(`**Prefix =** \`${config.prefix}\`\n**Bot Version =** \`${version}\``)
// 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'));
data.push(`\nType\`${config.prefix}help [command]\` for more information about a specific command.`);
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);
console.log(leeks.colors.yellow(leeks.styles.bold(`[WARN] Could not DM help menu to ${message.author.tag}, sending to server channel instead`)));
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 });
}

View File

@ -74,11 +74,13 @@ client.once('ready', () => { // after bot has logged in
console.log(leeks.colors.yellow(leeks.styles.bold(homepage)));
console.log('');
console.log(`Starting up...`)
console.log(leeks.colors.cyan(`Initialising bot...`))
for (const file of commands) {
const command = require(`./commands/${file}`);
client.commands.set(command.name, command);
console.log(`> Loading '${config.prefix}${command.name}' command`);
}
console.log(leeks.colors.green(`Connected to Discord API`))
console.log(leeks.colors.green(`Logged in as ${client.user.tag}`))
client.user.setPresence({
game: {
@ -103,6 +105,7 @@ client.once('ready', () => { // after bot has logged in
client.channels.get(config.logChannel).send(":white_check_mark: **Started succesfully**")
}
if (client.guilds.get(config.guildID).member(client.user).hasPermission("ADMINISTRATOR", false)) {
console.log(leeks.colors.bgYellowBright(leeks.colors.black(`Checking permissions...`)))
console.log(leeks.colors.green(`Required permissions have been granted`))
if (config.useEmbeds) {
const embed = new Discord.RichEmbed()
@ -244,7 +247,7 @@ process.on('unhandledRejection', error => {
console.log(leeks.colors.yellow(leeks.styles.bold(`[WARN] An error was not caught`)));
console.error(leeks.colors.red(`[ERROR] Uncaught Promise Error: \n${error.stack}`));
});
process.on('exit', (code) => {
process.on('beforeExit', (code) => {
console.log(leeks.colors.yellow(`Disconected from Discord API`));
console.log(leeks.colors.yellow(`Exiting (${code})`));
});