#whenever i put the slash command in the

1 messages · Page 1 of 1 (latest)

opaque bobcat
#

thread

astral socket
#

maybe problem is in your handler

bleak plume
#

ill put the code here

opaque bobcat
#

no

bleak plume
#

wat

opaque bobcat
#

just pastebin it

astral socket
#

use pastebin

bleak plume
#

ok

astral socket
#

yeah

opaque bobcat
#

xd

astral socket
#

i sent it 2 seconds before u but i have so bad internet today xD

opaque bobcat
#

or not requiring the file

#

xddd

astral socket
opaque bobcat
#

100mbit

#

not all too great

astral socket
opaque bobcat
#

still pissed i have to use MessageAttachment instead of using the path to attach a file to an embed

bleak plume
#

pastebiin is shit

opaque bobcat
#

eh

bleak plume
#

i will paste here

#
const fs = require('node:fs');
const path = require('node:path');
const { Client, Collection, Intents } = require('discord.js');
const { token } = require('./config.json');

const client = new Client({ intents: [Intents.FLAGS.GUILDS] });

client.commands = new Collection();
const commandsPath = path.join(__dirname, 'commands');
const commandFiles = fs.readdirSync("./commands").filter(file => file.endsWith('.js'));

for (const file of commandFiles) {
    const filePath = path.join(commandsPath, file);
    const command = require(filePath);
    client.commands.set(command.data.name, command);
}

client.once('ready', () => {
    console.log('Ready!');
});


client.on('interactionCreate', async interaction => {
    if (!interaction.isCommand()) return;

    const command = client.commands.get(interaction.commandName);

    if (!command) return;

    try {
        await command.execute(interaction);
    } catch (error) {
        console.error(error);
        await interaction.reply({ content: 'There was an error while executing this command!', ephemeral: true });
    }
});

client.login(token);```
#

this is the index

#
const fs = require('node:fs');
const path = require('node:path');
const { REST } = require('@discordjs/rest');
const { Routes } = require('discord-api-types/v9');
const { clientId, guildId, token } = require('./config.json');

const commands = [];
const commandsPath = path.join(__dirname, 'commands');
const commandFiles = fs.readdirSync(commandsPath).filter(file => file.endsWith('.js'));

for (const file of commandFiles) {
    const filePath = path.join(commandsPath, file);
    const command = require(filePath);
    commands.push(command.data.toJSON());
}

const rest = new REST({ version: '9' }).setToken(token);

rest.put(Routes.applicationGuildCommands(clientId, guildId), { body: commands })
    .then(() => console.log('Successfully registered application commands.'))
    .catch(console.error);

deploy-commands.js

opaque bobcat
#

why do ppl use different files for commands

#

just make one and import that

bleak plume
#

how

#

can i inv u to my repl?

#

@opaque bobcat

opaque bobcat
#

nope

#

i dont do this command stuff

#

sorry, way too messy and prone to errors

bleak plume
#

oh

#

i see