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•3mo 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•3mo ago
Alix
AlixOP•3mo ago
not receiving any error at all
Syjalo
Syjalo•3mo ago
Did you deploy the command?
Alix
AlixOP•3mo 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•3mo 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•3mo ago
alright i will fix that later on but to answer your question then yeah, i did deploy my command
Syjalo
Syjalo•3mo ago
Now restart your Discord app (Ctrl + R)
Alix
AlixOP•3mo 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•3mo ago
Log your commands. Is the subcommand there?
Alix
AlixOP•3mo ago
you mean like this
No description
Syjalo
Syjalo•3mo ago
No, the full command data
Alix
AlixOP•3mo 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•3mo ago
Have you used the shortcut, not just closed and open the app?
Alix
AlixOP•3mo ago
i tried both tbh
NyR
NyR•3mo 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•3mo 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•3mo ago
What does it show in discord? Can you show that?
Alix
AlixOP•3mo ago
No description
NyR
NyR•3mo ago
Yeah so you did not re deploy
Alix
AlixOP•3mo ago
it does automatically right when restarting the bot
Syjalo
Syjalo•3mo ago
Add console.log(interaction.commandGuildId) to your command execute function. Does it log the id?
Alix
AlixOP•3mo 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•3mo ago
Probably you didn't save the file
Alix
AlixOP•3mo 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?