Adding SubCommand to commands.
I'm using this snippet to load my slash commands.
Here is an example of a command in that ./command file
How would i add a SubCommand and other arguments to that command? I can't figure it out
Also feel free to ping me! :D
// Function to register commands from the "./commands" directory
const registerCommands = async () => {
const commandFiles = await fsPromises.readdir("./commands");
for (const file of commandFiles) {
const command = require(`./commands/${file}`);
if (command && command.name) {
client.commands.set(command.name, command);
handlers.logHandler.log(`Registered Command ${command.name}`, 1);
} else {
handlers.logHandler.log(
`Command ${file} is missing data or name property. Skipping.`,
2
);
}
}
};// Function to register commands from the "./commands" directory
const registerCommands = async () => {
const commandFiles = await fsPromises.readdir("./commands");
for (const file of commandFiles) {
const command = require(`./commands/${file}`);
if (command && command.name) {
client.commands.set(command.name, command);
handlers.logHandler.log(`Registered Command ${command.name}`, 1);
} else {
handlers.logHandler.log(
`Command ${file} is missing data or name property. Skipping.`,
2
);
}
}
};Here is an example of a command in that ./command file
const handlers = require("../handlerLoader.js");
const { client } = require("../index");
module.exports = {
name: "embed",
description:
"Send a specific embed to the channel you execute this command in.",
async execute(interaction) {
try {
const guild = await client.guilds.fetch(interaction.guild.id);
const member = await guild.members.fetch(interaction.user.id);
const isAdmin = member.permissions.has(PermissionFlagsBits.Administrator);
console.log(isAdmin)
} catch (error) {
console.error(`Error in hasAdminPermissions: ${error}`);
return false;
}
}
};const handlers = require("../handlerLoader.js");
const { client } = require("../index");
module.exports = {
name: "embed",
description:
"Send a specific embed to the channel you execute this command in.",
async execute(interaction) {
try {
const guild = await client.guilds.fetch(interaction.guild.id);
const member = await guild.members.fetch(interaction.user.id);
const isAdmin = member.permissions.has(PermissionFlagsBits.Administrator);
console.log(isAdmin)
} catch (error) {
console.error(`Error in hasAdminPermissions: ${error}`);
return false;
}
}
};How would i add a SubCommand and other arguments to that command? I can't figure it out
Also feel free to ping me! :D
