2022-08-14 05:51:45 -04:00
|
|
|
/* eslint-disable no-var */
|
|
|
|
/* eslint-disable max-len */
|
|
|
|
const {MessageEmbed} = require('discord.js');
|
|
|
|
module.exports = {
|
|
|
|
name: 'help',
|
|
|
|
alias: ['heko', 'cmds', 'commands'],
|
|
|
|
description: 'Shows the help',
|
|
|
|
usage: '[command]',
|
|
|
|
trusted: 0,
|
|
|
|
execute: function(bot, username, usernameraw, sender, prefix, args) {
|
|
|
|
let generalCommands = '';
|
|
|
|
let trustedCommands = '';
|
|
|
|
let ownerCommands = '';
|
|
|
|
for (const command of bot.command_handler.commands) {
|
|
|
|
if (command.trusted!==0) continue;
|
|
|
|
generalCommands += ' ' + command.name;
|
|
|
|
}
|
|
|
|
for (const command of bot.command_handler.commands) {
|
|
|
|
if (command.trusted!==1) continue;
|
|
|
|
trustedCommands += ' ' + command.name;
|
|
|
|
}
|
|
|
|
for (const command of bot.command_handler.commands) {
|
|
|
|
if (command.trusted!==2) continue;
|
|
|
|
ownerCommands += ' ' + command.name;
|
|
|
|
}
|
|
|
|
if (typeof args[0]!=='undefined') {
|
|
|
|
for (const command of bot.command_handler.commands) {
|
|
|
|
function m() {
|
|
|
|
let discordSupported;
|
|
|
|
let alias = command.name;
|
|
|
|
if (typeof command.discordExecute==='undefined') {
|
|
|
|
discordSupported = 'false';
|
|
|
|
} else {
|
|
|
|
discordSupported = 'true';
|
|
|
|
}
|
|
|
|
if (command.alias.toString()!=='') {
|
|
|
|
alias = command.alias.join(', ');
|
|
|
|
}
|
|
|
|
bot.core.run('minecraft:tellraw @a ' + JSON.stringify([{text: prefix + command.name, color: 'gold'}, {text: ` (${alias})`, color: 'white'}, {text: ' - ', color: 'gray'}, {text: command.description, color: 'gray'}]));
|
|
|
|
bot.core.run('minecraft:tellraw @a ' + JSON.stringify([{text: 'Trust level: ', color: 'green'}, {text: command.trusted, color: 'yellow'}]));
|
|
|
|
bot.core.run('minecraft:tellraw @a ' + JSON.stringify([{text: 'Supported on Discord: ', color: 'green'}, {text: discordSupported, color: 'gold'}]));
|
|
|
|
bot.core.run('minecraft:tellraw @a ' + JSON.stringify([{text: prefix + command.name, color: 'gold'}, {text: ' ' + command.usage, color: 'aqua'}]));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (command.name===args[0]) m();
|
|
|
|
for (const alias of command.alias) {
|
|
|
|
if (alias===args[0]) m();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
} else {
|
|
|
|
const pre = [{'text': 'Commands ', 'color': 'gray'}, {'text': '(', 'color': 'gray'}, {'text': '⬤ Public', 'color': 'green'}, {'text': ' ⬤ Trusted', 'color': 'red'}, {'text': ' ⬤ Owner', 'color': 'dark_red'}, {'text': ') -', 'color': 'gray'}];
|
|
|
|
bot.core.run('minecraft:tellraw @a ' + JSON.stringify([pre, {text: generalCommands, color: 'green'}, {text: trustedCommands, color: 'red'}, {text: ownerCommands, color: 'dark_red'}]));
|
|
|
|
}
|
|
|
|
},
|
|
|
|
discordExecute: function(bot, username, usernameraw, sender, prefix, args, channeldc) {
|
|
|
|
if (typeof args[0]!=='undefined') {
|
2022-10-14 04:46:41 -04:00
|
|
|
let sent = false;
|
|
|
|
|
2022-08-14 05:51:45 -04:00
|
|
|
for (const command of bot.command_handler.commands) {
|
|
|
|
if (command.name===args[0]) {
|
|
|
|
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}`)
|
2022-10-14 04:46:41 -04:00
|
|
|
.setDescription(`Trust level: ${command.trusted}` + '\n' + `${prefix + command.name} ${command.usage}` + '\n' + `Supported: ${discordSupported}`);
|
2022-08-14 05:51:45 -04:00
|
|
|
channeldc.send({embeds: [Embed]});
|
2022-10-14 04:46:41 -04:00
|
|
|
|
|
|
|
sent = true;
|
2022-08-14 05:51:45 -04:00
|
|
|
}
|
2022-10-14 04:46:41 -04:00
|
|
|
if (!sent) throw new SyntaxError('Invalid command');
|
2022-08-14 05:51:45 -04:00
|
|
|
};
|
|
|
|
} else {
|
|
|
|
let supportedCommands = '';
|
|
|
|
let unsupportedCommands = '';
|
|
|
|
for (const command of bot.command_handler.commands) {
|
|
|
|
if (typeof command.discordExecute==='undefined') continue;
|
|
|
|
supportedCommands += command.name + ' ';
|
|
|
|
}
|
|
|
|
for (const command of bot.command_handler.commands) {
|
|
|
|
if (typeof command.discordExecute!=='undefined') continue;
|
|
|
|
unsupportedCommands += command.name + ' ';
|
|
|
|
}
|
|
|
|
const Embed = new MessageEmbed()
|
|
|
|
.setColor('#FFFF00')
|
|
|
|
.setTitle('Commands')
|
|
|
|
.setDescription('**Supported Commands**\n' + supportedCommands + '\n**Unsupported Commands**\n' + unsupportedCommands);
|
|
|
|
channeldc.send({embeds: [Embed]});
|
|
|
|
}
|
|
|
|
},
|
|
|
|
};
|