improve help on both discord and mc

This commit is contained in:
ChomeNS 2022-11-23 16:43:28 +07:00
parent 90b7d09650
commit 9564b45570

View file

@ -9,45 +9,11 @@ module.exports = {
usage: '[command]',
trusted: 0,
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') {
for (const command of bot.command_handler.commands) {
function run() {
let discordSupported;
let alias = command.name;
if (typeof command.discordExecute === 'undefined') discordSupported = 'false';
else discordSupported = 'true';
if (command.alias.toString() !== '') {
alias = command.alias.join(', ');
}
@ -65,10 +31,27 @@ module.exports = {
usage.pop();
}
bot.tellraw(selector, [{text: prefix + command.name, color: 'gold'}, {text: ` (${alias})`, color: 'white'}, {text: ' - ', color: 'gray'}, {text: command.description, color: 'gray'}]);
bot.tellraw(selector, [{text: 'Trust level: ', color: 'green'}, {text: command.trusted, color: 'yellow'}]);
bot.tellraw(selector, [{text: 'Supported on Discord: ', color: 'green'}, {text: discordSupported, color: 'gold'}]);
bot.tellraw(selector, usage);
const component = [];
component.push({text: prefix + command.name, color: 'gold'});
component.push({text: ` (${alias})`, color: 'white'});
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();
@ -77,6 +60,39 @@ module.exports = {
}
};
} 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'}];
bot.tellraw(selector, [pre, generalCommands, trustedCommands, ownerCommands]);
}
@ -85,19 +101,17 @@ module.exports = {
if (typeof args[0] !== 'undefined') {
for (const command of bot.command_handler.commands) {
function run() {
let discordSupported;
let alias = command.name;
if (typeof command.discordExecute === 'undefined') discordSupported = 'false';
else discordSupported = 'true';
if (command.alias.toString() !== '') {
alias = command.alias.join(', ');
}
const Embed = new MessageEmbed()
.setColor('#FFFF00')
.setTitle(`${prefix + command.name} (${alias}) - ${command.description}`)
.setDescription(`Trust level: ${command.trusted}` + '\n' +
`Supported: ${discordSupported}` + '\n' +
`${prefix + command.name} ${command.usage}`,
.setDescription(`Trust level: ${command.trusted}
Supported: ${command.discordExecute ? 'true' : 'false'}
${prefix + command.name} ${command.usage}`,
);
channeldc.send({embeds: [Embed]});
}