2022-12-05 03:16:48 -05:00
|
|
|
|
2022-08-14 05:51:45 -04:00
|
|
|
/* eslint-disable no-var */
|
2022-12-24 00:59:52 -05:00
|
|
|
const { EmbedBuilder } = require('discord.js')
|
2022-08-14 05:51:45 -04:00
|
|
|
module.exports = {
|
|
|
|
name: 'help',
|
|
|
|
alias: ['heko', 'cmds', 'commands'],
|
|
|
|
description: 'Shows the help',
|
|
|
|
usage: '[command]',
|
|
|
|
trusted: 0,
|
2022-12-14 08:51:30 -05:00
|
|
|
execute (bot, username, sender, prefix, args, config, hash, ownerhash, selector) {
|
2022-11-26 02:54:05 -05:00
|
|
|
if (args[0]) {
|
2022-08-14 05:51:45 -04:00
|
|
|
for (const command of bot.command_handler.commands) {
|
2022-11-27 02:35:28 -05:00
|
|
|
function run () {
|
|
|
|
let alias = command.name
|
2022-11-23 04:43:28 -05:00
|
|
|
|
2022-11-07 08:08:29 -05:00
|
|
|
if (command.alias.toString() !== '') {
|
2022-11-27 02:35:28 -05:00
|
|
|
alias = command.alias.join(', ')
|
2022-08-14 05:51:45 -04:00
|
|
|
}
|
2022-11-13 01:52:37 -05:00
|
|
|
|
2022-11-27 02:35:28 -05:00
|
|
|
const usage = []
|
2022-11-13 01:52:37 -05:00
|
|
|
if (typeof command.usage === 'string') {
|
2022-11-27 02:35:28 -05:00
|
|
|
usage.push({ text: `${prefix}${command.name} `, color: 'gold' })
|
|
|
|
usage.push({ text: command.usage, color: 'aqua' })
|
2022-11-13 01:52:37 -05:00
|
|
|
} else {
|
|
|
|
command.usage.forEach((value) => {
|
2022-11-27 02:35:28 -05:00
|
|
|
usage.push({ text: `${prefix}${command.name} `, color: 'gold' })
|
|
|
|
usage.push({ text: value, color: 'aqua' })
|
|
|
|
usage.push('\n')
|
|
|
|
})
|
|
|
|
usage.pop()
|
2022-11-13 01:52:37 -05:00
|
|
|
}
|
|
|
|
|
2022-11-27 02:35:28 -05:00
|
|
|
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' })
|
2022-11-23 04:43:28 -05:00
|
|
|
|
2022-11-27 02:35:28 -05:00
|
|
|
component.push('\n')
|
2022-11-23 04:43:28 -05:00
|
|
|
|
2022-11-27 02:35:28 -05:00
|
|
|
component.push({ text: 'Trust level: ', color: 'green' })
|
|
|
|
component.push({ text: command.trusted, color: 'yellow' })
|
2022-11-23 04:43:28 -05:00
|
|
|
|
2022-11-27 02:35:28 -05:00
|
|
|
component.push('\n')
|
2022-11-23 04:43:28 -05:00
|
|
|
|
2022-11-27 02:35:28 -05:00
|
|
|
component.push({ text: 'Supported on Discord: ', color: 'green' })
|
|
|
|
component.push({ text: command.discordExecute ? 'true' : 'false', color: 'gold' })
|
2022-11-23 04:43:28 -05:00
|
|
|
|
2022-11-27 02:35:28 -05:00
|
|
|
component.push('\n')
|
2022-11-23 04:43:28 -05:00
|
|
|
|
2022-11-27 02:35:28 -05:00
|
|
|
component.push(usage)
|
2022-11-23 04:43:28 -05:00
|
|
|
|
2022-11-27 02:35:28 -05:00
|
|
|
bot.tellraw(selector, component)
|
2022-08-14 05:51:45 -04:00
|
|
|
}
|
|
|
|
|
2022-11-27 02:35:28 -05:00
|
|
|
if (command.name === args[0]) run()
|
2022-08-14 05:51:45 -04:00
|
|
|
for (const alias of command.alias) {
|
2022-11-27 02:35:28 -05:00
|
|
|
if (alias === args[0]) run()
|
2022-08-14 05:51:45 -04:00
|
|
|
}
|
|
|
|
};
|
|
|
|
} else {
|
2022-11-27 02:35:28 -05:00
|
|
|
const generalCommands = []
|
|
|
|
const trustedCommands = []
|
|
|
|
const ownerCommands = []
|
|
|
|
function component (command, color) {
|
2022-11-23 04:43:28 -05:00
|
|
|
return {
|
|
|
|
text: command.name + ' ',
|
|
|
|
color,
|
|
|
|
hoverEvent: {
|
|
|
|
action: 'show_text',
|
|
|
|
contents: [{
|
|
|
|
text: 'Click here to see the information for this command',
|
2022-11-27 02:35:28 -05:00
|
|
|
color: 'green'
|
|
|
|
}]
|
2022-11-23 04:43:28 -05:00
|
|
|
},
|
|
|
|
clickEvent: {
|
|
|
|
action: 'run_command',
|
2022-11-27 02:35:28 -05:00
|
|
|
value: `${prefix}help ${command.name}`
|
|
|
|
}
|
|
|
|
}
|
2022-11-23 04:43:28 -05:00
|
|
|
};
|
|
|
|
for (const command of bot.command_handler.commands) {
|
2022-12-12 06:37:29 -05:00
|
|
|
if (command.trusted !== 0 || command.proxy) continue
|
2022-11-27 02:35:28 -05:00
|
|
|
generalCommands.push(component(command, 'green'))
|
2022-11-23 04:43:28 -05:00
|
|
|
}
|
|
|
|
for (const command of bot.command_handler.commands) {
|
2022-12-12 06:37:29 -05:00
|
|
|
if (command.trusted !== 1 || command.proxy) continue
|
2022-11-27 02:35:28 -05:00
|
|
|
trustedCommands.push(component(command, 'red'))
|
2022-11-23 04:43:28 -05:00
|
|
|
}
|
|
|
|
for (const command of bot.command_handler.commands) {
|
2022-12-12 06:37:29 -05:00
|
|
|
if (command.trusted !== 2 || command.proxy) continue
|
2022-11-27 02:35:28 -05:00
|
|
|
ownerCommands.push(component(command, 'dark_red'))
|
2022-11-23 04:43:28 -05:00
|
|
|
}
|
|
|
|
|
2023-01-07 00:59:31 -05:00
|
|
|
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' }]
|
2022-11-27 02:35:28 -05:00
|
|
|
bot.tellraw(selector, [pre, generalCommands, trustedCommands, ownerCommands])
|
2022-08-14 05:51:45 -04:00
|
|
|
}
|
|
|
|
},
|
2022-12-14 08:51:30 -05:00
|
|
|
discordExecute: async function (bot, username, sender, prefix, args, channeldc, message, config) {
|
2022-11-26 02:54:05 -05:00
|
|
|
if (args[0]) {
|
2022-08-14 05:51:45 -04:00
|
|
|
for (const command of bot.command_handler.commands) {
|
2022-11-27 02:35:28 -05:00
|
|
|
function run () {
|
|
|
|
let alias = command.name
|
2022-11-23 04:43:28 -05:00
|
|
|
|
2022-11-07 08:08:29 -05:00
|
|
|
if (command.alias.toString() !== '') {
|
2022-11-27 02:35:28 -05:00
|
|
|
alias = command.alias.join(', ')
|
2022-08-14 05:51:45 -04:00
|
|
|
}
|
2022-12-24 00:59:52 -05:00
|
|
|
const Embed = new EmbedBuilder()
|
2022-12-01 05:15:30 -05:00
|
|
|
.setColor(config.discord.embedsColors.normal)
|
2022-11-27 02:35:28 -05:00
|
|
|
.setTitle(`${prefix + command.name} (${alias}) - ${command.description}`)
|
|
|
|
.setDescription(`Trust level: ${command.trusted}
|
2022-11-23 04:43:28 -05:00
|
|
|
Supported: ${command.discordExecute ? 'true' : 'false'}
|
2022-11-27 02:35:28 -05:00
|
|
|
${prefix + command.name} ${command.usage}`
|
|
|
|
)
|
|
|
|
channeldc.send({ embeds: [Embed] })
|
2022-10-15 00:45:40 -04:00
|
|
|
}
|
2022-10-14 04:46:41 -04:00
|
|
|
|
2022-11-27 02:35:28 -05:00
|
|
|
if (command.name === args[0]) run()
|
2022-10-15 00:45:40 -04:00
|
|
|
for (const alias of command.alias) {
|
2022-11-27 02:35:28 -05:00
|
|
|
if (alias === args[0]) run()
|
2022-08-14 05:51:45 -04:00
|
|
|
}
|
|
|
|
};
|
|
|
|
} else {
|
2022-11-27 02:35:28 -05:00
|
|
|
let supportedCommands = ''
|
|
|
|
let unsupportedCommands = ''
|
2022-08-14 05:51:45 -04:00
|
|
|
for (const command of bot.command_handler.commands) {
|
2022-11-27 02:35:28 -05:00
|
|
|
if (!command.discordExecute) continue
|
|
|
|
supportedCommands += command.name + ' '
|
2022-08-14 05:51:45 -04:00
|
|
|
}
|
|
|
|
for (const command of bot.command_handler.commands) {
|
2022-12-12 06:37:29 -05:00
|
|
|
if (command.discordExecute || command.proxy) continue
|
2022-11-27 02:35:28 -05:00
|
|
|
unsupportedCommands += command.name + ' '
|
2022-08-14 05:51:45 -04:00
|
|
|
}
|
2022-12-24 00:59:52 -05:00
|
|
|
const Embed = new EmbedBuilder()
|
2022-12-01 05:15:30 -05:00
|
|
|
.setColor(config.discord.embedsColors.normal)
|
2022-11-27 02:35:28 -05:00
|
|
|
.setTitle(`Commands (Length: ${bot.command_handler.commands.length})`)
|
|
|
|
.setDescription('**Supported Commands**\n' + supportedCommands + '\n**Unsupported Commands**\n' + unsupportedCommands)
|
|
|
|
channeldc.send({ embeds: [Embed] })
|
2022-08-14 05:51:45 -04:00
|
|
|
}
|
2022-11-27 02:35:28 -05:00
|
|
|
}
|
|
|
|
}
|