Alix
Alix
Explore posts from servers
DIAdiscord.js - Imagine an app
Created by Alix on 2/13/2025 in #djs-questions
subcommand not showing
next time i also gonna try to add some console.logs maybe it will refresh then 😄
34 replies
DIAdiscord.js - Imagine an app
Created by Alix on 2/13/2025 in #djs-questions
subcommand not showing
but it is fixed so whatever
34 replies
DIAdiscord.js - Imagine an app
Created by Alix on 2/13/2025 in #djs-questions
subcommand not showing
always the first time i do check
34 replies
DIAdiscord.js - Imagine an app
Created by Alix on 2/13/2025 in #djs-questions
subcommand not showing
i did 😄
34 replies
DIAdiscord.js - Imagine an app
Created by Alix on 2/13/2025 in #djs-questions
subcommand not showing
wtf
34 replies
DIAdiscord.js - Imagine an app
Created by Alix on 2/13/2025 in #djs-questions
subcommand not showing
after adding this console log it did refresh
34 replies
DIAdiscord.js - Imagine an app
Created by Alix on 2/13/2025 in #djs-questions
subcommand not showing
now i do get this error This command is outdated, please try again in a few minutes
34 replies
DIAdiscord.js - Imagine an app
Created by Alix on 2/13/2025 in #djs-questions
subcommand not showing
it does automatically right when restarting the bot
34 replies
DIAdiscord.js - Imagine an app
Created by Alix on 2/13/2025 in #djs-questions
subcommand not showing
No description
34 replies
DIAdiscord.js - Imagine an app
Created by Alix on 2/13/2025 in #djs-questions
subcommand not showing
this is correct deploying right so i don't see the issue then
34 replies
DIAdiscord.js - Imagine an app
Created by Alix on 2/13/2025 in #djs-questions
subcommand not showing
i just do get this return content: '❌ Please specify a valid subcommand. Use /instagram config setup or /instagram config status.',
34 replies
DIAdiscord.js - Imagine an app
Created by Alix on 2/13/2025 in #djs-questions
subcommand not showing
i tried both tbh
34 replies
DIAdiscord.js - Imagine an app
Created by Alix on 2/13/2025 in #djs-questions
subcommand not showing
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
}
34 replies
DIAdiscord.js - Imagine an app
Created by Alix on 2/13/2025 in #djs-questions
subcommand not showing
No description
34 replies
DIAdiscord.js - Imagine an app
Created by Alix on 2/13/2025 in #djs-questions
subcommand not showing
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;
}
34 replies
DIAdiscord.js - Imagine an app
Created by Alix on 2/13/2025 in #djs-questions
subcommand not showing
i already tried
34 replies
DIAdiscord.js - Imagine an app
Created by Alix on 2/13/2025 in #djs-questions
subcommand not showing
but to answer your question then yeah, i did deploy my command
34 replies
DIAdiscord.js - Imagine an app
Created by Alix on 2/13/2025 in #djs-questions
subcommand not showing
alright i will fix that later on
34 replies
DIAdiscord.js - Imagine an app
Created by Alix on 2/13/2025 in #djs-questions
subcommand not showing
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`);
34 replies
DIAdiscord.js - Imagine an app
Created by Alix on 2/13/2025 in #djs-questions
subcommand not showing
not receiving any error at all
34 replies