subcommand not showing

When i try to do the instagram command the subcommand isn't showing
No description
25 Replies
d.js toolkit
d.js toolkitā€¢2w ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button!
Alix
AlixOPā€¢2w ago
Alix
AlixOPā€¢2w ago
not receiving any error at all
Syjalo
Syjaloā€¢2w ago
Did you deploy the command?
Alix
AlixOPā€¢2w ago
you mean like this
await client.application?.commands.fetch();
await client.application?.commands.set(commands);
console.log(`Synced ${commands.length} commands globally`);
await client.application?.commands.fetch();
await client.application?.commands.set(commands);
console.log(`Synced ${commands.length} commands globally`);
Syjalo
Syjaloā€¢2w ago
Yeah, but don't deploy commands each bot startup. You can be rate limited easily. It's better to have a separate file and run it when you have done changes to the data
Alix
AlixOPā€¢2w ago
alright i will fix that later on but to answer your question then yeah, i did deploy my command
Syjalo
Syjaloā€¢2w ago
Now restart your Discord app (Ctrl + R)
Alix
AlixOPā€¢2w ago
i already tried and it has nothing to do with this file right
import { Client, Collection, ApplicationCommandData } from "discord.js";
import fs from "fs";
import path from "path";
import { fileURLToPath, pathToFileURL } from "url";
import dotenv from "dotenv";

dotenv.config();

const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);

// šŸ‘‡ Make sure it loads from the correct directory
const commandsDir = path.join(__dirname, "../commands");

function getCommandFiles(dir: string): string[] {
return fs.readdirSync(dir, { withFileTypes: true })
.flatMap(dirent =>
dirent.isDirectory()
? getCommandFiles(path.join(dir, dirent.name))
: dirent.name.endsWith(".ts") && !dirent.name.includes("handler")
? path.join(dir, dirent.name)
: []
);
}


export async function setupCommandHandler(client: Client): Promise<ApplicationCommandData[]> {
if (!client.commands) client.commands = new Collection();

const commandFiles = getCommandFiles(commandsDir);
const commands: ApplicationCommandData[] = [];

console.log(`šŸ” Found ${commandFiles.length} command files`);

for (const filePath of commandFiles) {
try {
const commandModule = await import(pathToFileURL(filePath).href);
const command = commandModule.default || commandModule;

if (command?.data?.name) {
client.commands.set(command.data.name, command);
commands.push(command.data.toJSON());
console.log(`āœ… Loaded command: ${command.data.name}`);
} else {
console.log(`āš ļø Skipping invalid command file: ${filePath}`);
}
} catch (error) {
console.error(`āŒ Error loading command from ${filePath}:`, error);
}
}

return commands;
}
import { Client, Collection, ApplicationCommandData } from "discord.js";
import fs from "fs";
import path from "path";
import { fileURLToPath, pathToFileURL } from "url";
import dotenv from "dotenv";

dotenv.config();

const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);

// šŸ‘‡ Make sure it loads from the correct directory
const commandsDir = path.join(__dirname, "../commands");

function getCommandFiles(dir: string): string[] {
return fs.readdirSync(dir, { withFileTypes: true })
.flatMap(dirent =>
dirent.isDirectory()
? getCommandFiles(path.join(dir, dirent.name))
: dirent.name.endsWith(".ts") && !dirent.name.includes("handler")
? path.join(dir, dirent.name)
: []
);
}


export async function setupCommandHandler(client: Client): Promise<ApplicationCommandData[]> {
if (!client.commands) client.commands = new Collection();

const commandFiles = getCommandFiles(commandsDir);
const commands: ApplicationCommandData[] = [];

console.log(`šŸ” Found ${commandFiles.length} command files`);

for (const filePath of commandFiles) {
try {
const commandModule = await import(pathToFileURL(filePath).href);
const command = commandModule.default || commandModule;

if (command?.data?.name) {
client.commands.set(command.data.name, command);
commands.push(command.data.toJSON());
console.log(`āœ… Loaded command: ${command.data.name}`);
} else {
console.log(`āš ļø Skipping invalid command file: ${filePath}`);
}
} catch (error) {
console.error(`āŒ Error loading command from ${filePath}:`, error);
}
}

return commands;
}
Syjalo
Syjaloā€¢2w ago
Log your commands. Is the subcommand there?
Alix
AlixOPā€¢2w ago
you mean like this
No description
Syjalo
Syjaloā€¢2w ago
No, the full command data
Alix
AlixOPā€¢2w ago
so like this
šŸ“ Command Structure for: instagram
{
"options": [
{
"type": 2,
"name": "config",
"description": "Configure Instagram integration",
"options": [
{
"type": 1,
"name": "setup",
"description": "Set up Instagram integration",
"options": [
{
"channel_types": [
0
],
"name": "channel",
"description": "Channel to post Instagram updates",
"required": true,
"type": 7
}
]
},
{
"type": 1,
"name": "status",
"description": "Check Instagram integration status",
"options": []
}
]
}
],
"name": "instagram",
"description": "Manage Instagram integration",
"default_member_permissions": "8",
"type": 1
}
šŸ“ Command Structure for: instagram
{
"options": [
{
"type": 2,
"name": "config",
"description": "Configure Instagram integration",
"options": [
{
"type": 1,
"name": "setup",
"description": "Set up Instagram integration",
"options": [
{
"channel_types": [
0
],
"name": "channel",
"description": "Channel to post Instagram updates",
"required": true,
"type": 7
}
]
},
{
"type": 1,
"name": "status",
"description": "Check Instagram integration status",
"options": []
}
]
}
],
"name": "instagram",
"description": "Manage Instagram integration",
"default_member_permissions": "8",
"type": 1
}
Syjalo
Syjaloā€¢2w ago
Have you used the shortcut, not just closed and open the app?
Alix
AlixOPā€¢2w ago
i tried both tbh
NyR
NyRā€¢2w ago
Did you try to run that command? If it is outdated discord will tell you and auto-refresh your commands, if not then you didn't deploy your commands properly
Alix
AlixOPā€¢2w ago
i just do get this return content: 'āŒ Please specify a valid subcommand. Use /instagram config setup or /instagram config status.', this is correct deploying right so i don't see the issue then
NyR
NyRā€¢2w ago
What does it show in discord? Can you show that?
Alix
AlixOPā€¢2w ago
No description
NyR
NyRā€¢2w ago
Yeah so you did not re deploy
Alix
AlixOPā€¢2w ago
it does automatically right when restarting the bot
Syjalo
Syjaloā€¢2w ago
Add console.log(interaction.commandGuildId) to your command execute function. Does it log the id?
Alix
AlixOPā€¢2w ago
now i do get this error This command is outdated, please try again in a few minutes after adding this console log it did refresh wtf
Syjalo
Syjaloā€¢2w ago
Probably you didn't save the file
Alix
AlixOPā€¢2w ago
i did šŸ˜„ always the first time i do check but it is fixed so whatever next time i also gonna try to add some console.logs maybe it will refresh then šŸ˜„

Did you find this page helpful?