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,6 +9,57 @@ 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) {
if (typeof args[0] !== 'undefined') {
for (const command of bot.command_handler.commands) {
function run() {
let alias = command.name;
if (command.alias.toString() !== '') {
alias = command.alias.join(', ');
}
const usage = [];
if (typeof command.usage === 'string') {
usage.push({text: `${prefix}${command.name} `, color: 'gold'});
usage.push({text: command.usage, color: 'aqua'});
} else {
command.usage.forEach((value) => {
usage.push({text: `${prefix}${command.name} `, color: 'gold'});
usage.push({text: value, color: 'aqua'});
usage.push('\n');
});
usage.pop();
}
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();
for (const alias of command.alias) {
if (alias === args[0]) run();
}
};
} else {
const generalCommands = []; const generalCommands = [];
const trustedCommands = []; const trustedCommands = [];
const ownerCommands = []; const ownerCommands = [];
@ -41,42 +92,7 @@ module.exports = {
if (command.trusted !== 2) continue; if (command.trusted !== 2) continue;
ownerCommands.push(component(command, 'dark_red')); 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(', ');
}
const usage = [];
if (typeof command.usage === 'string') {
usage.push({text: `${prefix}${command.name} `, color: 'gold'});
usage.push({text: command.usage, color: 'aqua'});
} else {
command.usage.forEach((value) => {
usage.push({text: `${prefix}${command.name} `, color: 'gold'});
usage.push({text: value, color: 'aqua'});
usage.push('\n');
});
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);
}
if (command.name === args[0]) run();
for (const alias of command.alias) {
if (alias === args[0]) run();
}
};
} else {
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]});
} }