Updated help command to include subcommands

This commit is contained in:
2023-12-05 15:29:41 +01:00
parent df82a66921
commit cf42d05d89
2 changed files with 28 additions and 2 deletions

View File

@@ -9,6 +9,16 @@ module.exports = {
type: "slash", type: "slash",
dev: false, dev: false,
public: true, public: true,
subcommands: [
{
name: "member",
description: "Get info about a guild memeber",
},
{
name: "info",
description: "Get info about a guild.",
}
],
data: new SlashCommandBuilder() data: new SlashCommandBuilder()
.setName("guild") .setName("guild")

View File

@@ -6,7 +6,7 @@ module.exports = {
name: "help", name: "help",
description: "Help command", description: "Help command",
type: "slash", type: "slash",
dev: false, dev: true,
public: true, public: true,
data: new SlashCommandBuilder() data: new SlashCommandBuilder()
@@ -24,10 +24,26 @@ module.exports = {
const commandFiles = fs.readdirSync(__dirname).filter(file => file.endsWith(".js")) const commandFiles = fs.readdirSync(__dirname).filter(file => file.endsWith(".js"))
for (const file of commandFiles) { for (const file of commandFiles) {
const command = require(`./${file}`) const command = require(`./${file}`)
if (command.public) { if (command.public && !command.subcommands) {
commands.push(command) commands.push(command)
} else if (command.public && command.subcommands) {
const commandName = command.name
const subcommands = command.subcommands.map((subcommand) => {
return {
name: commandName + " " + subcommand.name,
description: subcommand.description
}
})
console.log(subcommands)
for (const subcommand of subcommands) {
commands.push(subcommand)
} }
} }
}
const commandList = commands.map((command) => { const commandList = commands.map((command) => {
return { return {
name: "**/" + command.name + "**", name: "**/" + command.name + "**",