Improving the dynamic help
This commit is contained in:
parent
ab0f4b316d
commit
5236462efe
@ -14,6 +14,7 @@ let options = {
|
|||||||
module.exports = {
|
module.exports = {
|
||||||
name: 'airport',
|
name: 'airport',
|
||||||
description: 'Get airport information by IATA code.',
|
description: 'Get airport information by IATA code.',
|
||||||
|
usage: '<IATA>',
|
||||||
execute(message, file) {
|
execute(message, file) {
|
||||||
options.params.airport_id = file.name;
|
options.params.airport_id = file.name;
|
||||||
axios.request(options).then(function (response) {
|
axios.request(options).then(function (response) {
|
||||||
|
@ -10,6 +10,7 @@ const tenor = require('tenorjs').client({
|
|||||||
module.exports = {
|
module.exports = {
|
||||||
name: 'gif',
|
name: 'gif',
|
||||||
description: 'Send a GIF',
|
description: 'Send a GIF',
|
||||||
|
usage: '<GIF name or Search Query>',
|
||||||
execute(message, file) {
|
execute(message, file) {
|
||||||
const client = message.client;
|
const client = message.client;
|
||||||
if (!client.gifs.has(file.name)) {
|
if (!client.gifs.has(file.name)) {
|
||||||
|
@ -1,54 +1,13 @@
|
|||||||
|
const functions = require('../functions.js');
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
name: 'help',
|
name: 'help',
|
||||||
description: 'Shows the help page.',
|
description: 'Shows the help page.',
|
||||||
execute(message, file) {
|
execute(message, file) {
|
||||||
const data = [];
|
message.author.createDM()
|
||||||
const { commands } = message.client;
|
.then(dmChannel => {
|
||||||
|
dmChannel.send(functions.createHelpEmbed(message)).then().catch(err => console.error(err));
|
||||||
if (!file.name) {
|
message.reply('I\'ve DM\'d you a copy of my help message!');
|
||||||
// const helpStructure = {
|
}).catch(err => console.error(err));
|
||||||
// commands = [
|
|
||||||
// {
|
|
||||||
// name: commandName,
|
|
||||||
// aliases: commandAliases,
|
|
||||||
// description: commandDescription,
|
|
||||||
// usage: commandUsage,
|
|
||||||
// cooldown: commandCooldown
|
|
||||||
// }
|
|
||||||
// ]
|
|
||||||
// };
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
data.push('Here\'s a list of all my commands:');
|
|
||||||
data.push(commands.map(command => command.name).join(', '));
|
|
||||||
data.push('\nYou can send `[command name].help` to get info on a specific command!');
|
|
||||||
|
|
||||||
return message.author.send(data, { split: true })
|
|
||||||
.then(() => {
|
|
||||||
if (message.channel.type === 'dm') return;
|
|
||||||
message.reply('I\'ve sent you a DM with all my commands!');
|
|
||||||
})
|
|
||||||
.catch(error => {
|
|
||||||
console.error(`Could not send help DM to ${message.author.tag}.\n`, error);
|
|
||||||
message.reply('It seems like I can\'t DM you! Do you have DMs disabled?');
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
const command = commands.get(file.name) || commands.find(c => c.aliases && c.aliases.includes(file.name));
|
|
||||||
|
|
||||||
if (!command) {
|
|
||||||
return message.reply('That\'s not a valid command!');
|
|
||||||
}
|
|
||||||
|
|
||||||
data.push(`**Name:** ${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:** \`${command.usage}.${command.name}\``);
|
|
||||||
|
|
||||||
data.push(`**Cooldown:** ${command.cooldown || 3} second(s)`);
|
|
||||||
|
|
||||||
message.channel.send(data, { split: true });
|
|
||||||
},
|
},
|
||||||
};
|
};
|
@ -4,6 +4,6 @@ module.exports = {
|
|||||||
name: 'mapcommands',
|
name: 'mapcommands',
|
||||||
description: '',
|
description: '',
|
||||||
execute(message, file) {
|
execute(message, file) {
|
||||||
console.log(functions.mapCommands(message.client));
|
console.log(functions.mapCommands(message));
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -3,6 +3,7 @@ const functions = require('../functions.js');
|
|||||||
module.exports = {
|
module.exports = {
|
||||||
name: 'pasta',
|
name: 'pasta',
|
||||||
description: 'Send a copypasta.',
|
description: 'Send a copypasta.',
|
||||||
|
usage: '<Copypasta Name>',
|
||||||
execute(message, file) {
|
execute(message, file) {
|
||||||
const client = message.client;
|
const client = message.client;
|
||||||
const replyHeader = `\'${file.name}\' requested by: ${message.author.username}\n`;
|
const replyHeader = `\'${file.name}\' requested by: ${message.author.username}\n`;
|
||||||
|
@ -10,7 +10,7 @@ const { emoji } = require('../config.json');
|
|||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
name: 'savegif',
|
name: 'savegif',
|
||||||
description: 'Adds a given gif to the hardcoded list.',
|
description: 'Saves a gif selected from a search to a given filename.',
|
||||||
usage: '<search query>',
|
usage: '<search query>',
|
||||||
execute(message, file) {
|
execute(message, file) {
|
||||||
const query = file.name;
|
const query = file.name;
|
||||||
|
@ -2,8 +2,8 @@ const functions = require('../functions.js');
|
|||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
name: 'savepasta',
|
name: 'savepasta',
|
||||||
description: 'Adds a given copypasta to the hardcoded list.',
|
description: 'Saves a copypasta as pasta_name.pasta, just send the pasta name on the first message, and the bot will ask for the actual pasta afterwards.',
|
||||||
usage: '<Copy Pasta Text> <pasta_name>',
|
usage: '<Pasta Name>',
|
||||||
execute(message, file) {
|
execute(message, file) {
|
||||||
message.channel.send(`I'll be saving the next message you send as ${file.name}.pasta\nWhat is the content of the copypasta?`)
|
message.channel.send(`I'll be saving the next message you send as ${file.name}.pasta\nWhat is the content of the copypasta?`)
|
||||||
.then(promptMessage => {
|
.then(promptMessage => {
|
||||||
|
@ -3,7 +3,7 @@ const functions = require('../functions.js');
|
|||||||
module.exports = {
|
module.exports = {
|
||||||
name: 'spongebob',
|
name: 'spongebob',
|
||||||
description: 'SpOnGeBoB-iFy AnYtHiNg AuToMaTiCaLly',
|
description: 'SpOnGeBoB-iFy AnYtHiNg AuToMaTiCaLly',
|
||||||
usage: '<text you want spongebob-ified',
|
usage: '<text to convert>',
|
||||||
execute(message, file) {
|
execute(message, file) {
|
||||||
let flipper = 0;
|
let flipper = 0;
|
||||||
let newText = '';
|
let newText = '';
|
||||||
|
@ -14,6 +14,7 @@ var options = {
|
|||||||
module.exports = {
|
module.exports = {
|
||||||
name: 'weather',
|
name: 'weather',
|
||||||
description: 'Get the current weather by ZIP code or city name.',
|
description: 'Get the current weather by ZIP code or city name.',
|
||||||
|
usage: '<ZIP code, City Name, etc>',
|
||||||
execute(message, file) {
|
execute(message, file) {
|
||||||
options.params.q = file.name;
|
options.params.q = file.name;
|
||||||
axios.request(options).then(function (response) {
|
axios.request(options).then(function (response) {
|
||||||
|
49
functions.js
49
functions.js
@ -115,22 +115,39 @@ module.exports = {
|
|||||||
.setTimestamp()
|
.setTimestamp()
|
||||||
.setFooter(`@${author.username}#${author.discriminator}`);
|
.setFooter(`@${author.username}#${author.discriminator}`);
|
||||||
},
|
},
|
||||||
mapCommands(client) {
|
createHelpEmbed(message) {
|
||||||
const { commands } = client;
|
const { commands } = message.client;
|
||||||
// return new Promise((resolve, reject) => {
|
let fields = [];
|
||||||
// let commandMap = []
|
for (const entry of commands.map(command => [command.name, command.description, command.usage])) {
|
||||||
// for (const [key, value] of commands.map()) {
|
const name = entry[0];
|
||||||
// // commandMap.push({
|
const description = entry[1];
|
||||||
// // name: command.name,
|
let usage;
|
||||||
// // aliases: command.aliases,
|
if (entry[2] == undefined) {
|
||||||
// // description: command.description,
|
usage = '';
|
||||||
// // usage: command.usage,
|
} else {
|
||||||
// // cooldown: 0 // Set to 0 for now for the sake of simple code, will add cooldowns later
|
usage = entry[2];
|
||||||
// // });
|
}
|
||||||
// }
|
const excludeList = [
|
||||||
// });
|
'kill',
|
||||||
for (const entry of commands.map(command => [command.name, command.description, command.syntax])) {
|
'mapcommands',
|
||||||
console.log(entry);
|
'newgif',
|
||||||
|
'newpng',
|
||||||
|
'oldgif',
|
||||||
|
'strain',
|
||||||
|
'stonk',
|
||||||
|
'wrongbad'
|
||||||
|
];
|
||||||
|
if (excludeList.includes(name)) continue;
|
||||||
|
fields.push({
|
||||||
|
name: name,
|
||||||
|
value: `${description}\n**Usage:** \`${usage}.${name}\``
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return new Discord.MessageEmbed()
|
||||||
|
.setAuthor('NodBot Help')
|
||||||
|
.setDescription('All commands are provided as "file extensions" instead of prefixes to the message.')
|
||||||
|
.addFields(fields)
|
||||||
|
.setTimestamp();
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user