mirror of
https://github.com/ChomeNS/chomens-bot-mc.git
synced 2024-11-23 15:47:57 -05:00
improve help on both discord and mc
This commit is contained in:
parent
90b7d09650
commit
9564b45570
1 changed files with 59 additions and 45 deletions
104
commands/help.js
104
commands/help.js
|
@ -9,45 +9,11 @@ module.exports = {
|
||||||
usage: '[command]',
|
usage: '[command]',
|
||||||
trusted: 0,
|
trusted: 0,
|
||||||
execute: function(bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector) {
|
execute: function(bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector) {
|
||||||
const generalCommands = [];
|
|
||||||
const trustedCommands = [];
|
|
||||||
const ownerCommands = [];
|
|
||||||
function component(command, color) {
|
|
||||||
return {
|
|
||||||
text: command.name + ' ',
|
|
||||||
color,
|
|
||||||
hoverEvent: {
|
|
||||||
action: 'show_text',
|
|
||||||
contents: [{
|
|
||||||
text: 'Click here to see the information for this command',
|
|
||||||
color: 'green',
|
|
||||||
}],
|
|
||||||
},
|
|
||||||
clickEvent: {
|
|
||||||
action: 'run_command',
|
|
||||||
value: `${prefix}help ${command.name}`,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
};
|
|
||||||
for (const command of bot.command_handler.commands) {
|
|
||||||
if (command.trusted !== 0) continue;
|
|
||||||
generalCommands.push(component(command, 'green'));
|
|
||||||
}
|
|
||||||
for (const command of bot.command_handler.commands) {
|
|
||||||
if (command.trusted !== 1) continue;
|
|
||||||
trustedCommands.push(component(command, 'red'));
|
|
||||||
}
|
|
||||||
for (const command of bot.command_handler.commands) {
|
|
||||||
if (command.trusted !== 2) continue;
|
|
||||||
ownerCommands.push(component(command, 'dark_red'));
|
|
||||||
}
|
|
||||||
if (typeof args[0] !== 'undefined') {
|
if (typeof args[0] !== 'undefined') {
|
||||||
for (const command of bot.command_handler.commands) {
|
for (const command of bot.command_handler.commands) {
|
||||||
function run() {
|
function run() {
|
||||||
let discordSupported;
|
|
||||||
let alias = command.name;
|
let alias = command.name;
|
||||||
if (typeof command.discordExecute === 'undefined') discordSupported = 'false';
|
|
||||||
else discordSupported = 'true';
|
|
||||||
if (command.alias.toString() !== '') {
|
if (command.alias.toString() !== '') {
|
||||||
alias = command.alias.join(', ');
|
alias = command.alias.join(', ');
|
||||||
}
|
}
|
||||||
|
@ -65,10 +31,27 @@ module.exports = {
|
||||||
usage.pop();
|
usage.pop();
|
||||||
}
|
}
|
||||||
|
|
||||||
bot.tellraw(selector, [{text: prefix + command.name, color: 'gold'}, {text: ` (${alias})`, color: 'white'}, {text: ' - ', color: 'gray'}, {text: command.description, color: 'gray'}]);
|
const component = [];
|
||||||
bot.tellraw(selector, [{text: 'Trust level: ', color: 'green'}, {text: command.trusted, color: 'yellow'}]);
|
component.push({text: prefix + command.name, color: 'gold'});
|
||||||
bot.tellraw(selector, [{text: 'Supported on Discord: ', color: 'green'}, {text: discordSupported, color: 'gold'}]);
|
component.push({text: ` (${alias})`, color: 'white'});
|
||||||
bot.tellraw(selector, usage);
|
component.push({text: ' - ', color: 'gray'});
|
||||||
|
component.push({text: command.description, color: 'gray'});
|
||||||
|
|
||||||
|
component.push('\n');
|
||||||
|
|
||||||
|
component.push({text: 'Trust level: ', color: 'green'});
|
||||||
|
component.push({text: command.trusted, color: 'yellow'});
|
||||||
|
|
||||||
|
component.push('\n');
|
||||||
|
|
||||||
|
component.push({text: 'Supported on Discord: ', color: 'green'});
|
||||||
|
component.push({text: command.discordExecute ? 'true' : 'false', color: 'gold'});
|
||||||
|
|
||||||
|
component.push('\n');
|
||||||
|
|
||||||
|
component.push(usage);
|
||||||
|
|
||||||
|
bot.tellraw(selector, component);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (command.name === args[0]) run();
|
if (command.name === args[0]) run();
|
||||||
|
@ -77,6 +60,39 @@ module.exports = {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
|
const generalCommands = [];
|
||||||
|
const trustedCommands = [];
|
||||||
|
const ownerCommands = [];
|
||||||
|
function component(command, color) {
|
||||||
|
return {
|
||||||
|
text: command.name + ' ',
|
||||||
|
color,
|
||||||
|
hoverEvent: {
|
||||||
|
action: 'show_text',
|
||||||
|
contents: [{
|
||||||
|
text: 'Click here to see the information for this command',
|
||||||
|
color: 'green',
|
||||||
|
}],
|
||||||
|
},
|
||||||
|
clickEvent: {
|
||||||
|
action: 'run_command',
|
||||||
|
value: `${prefix}help ${command.name}`,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
};
|
||||||
|
for (const command of bot.command_handler.commands) {
|
||||||
|
if (command.trusted !== 0) continue;
|
||||||
|
generalCommands.push(component(command, 'green'));
|
||||||
|
}
|
||||||
|
for (const command of bot.command_handler.commands) {
|
||||||
|
if (command.trusted !== 1) continue;
|
||||||
|
trustedCommands.push(component(command, 'red'));
|
||||||
|
}
|
||||||
|
for (const command of bot.command_handler.commands) {
|
||||||
|
if (command.trusted !== 2) continue;
|
||||||
|
ownerCommands.push(component(command, 'dark_red'));
|
||||||
|
}
|
||||||
|
|
||||||
const pre = [{text: 'Commands ', color: 'gray'}, {text: '(', color: 'dark_gray'}, {text: 'Length: ', color: 'gray'}, {text: bot.command_handler.commands.length, color: 'green'}, {text: ') ', color: 'dark_gray'}, {text: '(', color: 'dark_gray'}, {text: '⬤ Public', color: 'green'}, {text: ' ⬤ Trusted', color: 'red'}, {text: ' ⬤ Owner', color: 'dark_red'}, {text: ') - ', color: 'dark_gray'}];
|
const pre = [{text: 'Commands ', color: 'gray'}, {text: '(', color: 'dark_gray'}, {text: 'Length: ', color: 'gray'}, {text: bot.command_handler.commands.length, color: 'green'}, {text: ') ', color: 'dark_gray'}, {text: '(', color: 'dark_gray'}, {text: '⬤ Public', color: 'green'}, {text: ' ⬤ Trusted', color: 'red'}, {text: ' ⬤ Owner', color: 'dark_red'}, {text: ') - ', color: 'dark_gray'}];
|
||||||
bot.tellraw(selector, [pre, generalCommands, trustedCommands, ownerCommands]);
|
bot.tellraw(selector, [pre, generalCommands, trustedCommands, ownerCommands]);
|
||||||
}
|
}
|
||||||
|
@ -85,19 +101,17 @@ module.exports = {
|
||||||
if (typeof args[0] !== 'undefined') {
|
if (typeof args[0] !== 'undefined') {
|
||||||
for (const command of bot.command_handler.commands) {
|
for (const command of bot.command_handler.commands) {
|
||||||
function run() {
|
function run() {
|
||||||
let discordSupported;
|
|
||||||
let alias = command.name;
|
let alias = command.name;
|
||||||
if (typeof command.discordExecute === 'undefined') discordSupported = 'false';
|
|
||||||
else discordSupported = 'true';
|
|
||||||
if (command.alias.toString() !== '') {
|
if (command.alias.toString() !== '') {
|
||||||
alias = command.alias.join(', ');
|
alias = command.alias.join(', ');
|
||||||
}
|
}
|
||||||
const Embed = new MessageEmbed()
|
const Embed = new MessageEmbed()
|
||||||
.setColor('#FFFF00')
|
.setColor('#FFFF00')
|
||||||
.setTitle(`${prefix + command.name} (${alias}) - ${command.description}`)
|
.setTitle(`${prefix + command.name} (${alias}) - ${command.description}`)
|
||||||
.setDescription(`Trust level: ${command.trusted}` + '\n' +
|
.setDescription(`Trust level: ${command.trusted}
|
||||||
`Supported: ${discordSupported}` + '\n' +
|
Supported: ${command.discordExecute ? 'true' : 'false'}
|
||||||
`${prefix + command.name} ${command.usage}`,
|
${prefix + command.name} ${command.usage}`,
|
||||||
);
|
);
|
||||||
channeldc.send({embeds: [Embed]});
|
channeldc.send({embeds: [Embed]});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue