kermiot $
DIAdiscord.js - Imagine an app
•Created by kermiot $ on 11/17/2024 in #djs-questions
selectmenu dont working
help plz
9 replies
DIAdiscord.js - Imagine an app
•Created by kermiot $ on 11/17/2024 in #djs-questions
selectmenu dont working
and index.js
const { Client, GatewayIntentBits, Collection } = require('discord.js');
const fs = require('fs');
const config = require('./config.json');
const { REST, Routes } = require('discord.js');
// Stwórz instancję klienta
const client = new Client({ intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildMessages, GatewayIntentBits.MessageContent] });
client.commands = new Collection();
// Załaduj komendy z folderu 'commands'
const commandFiles = fs.readdirSync('./commands').filter(file => file.endsWith('.js'));
for (const file of commandFiles) {
const command = require(
./commands/${file}
);
if (command.data && command.data.name) {
client.commands.set(command.data.name, command);
} else {
console.error(Komenda w pliku ${file} nie zawiera 'data.name'
);
}
}
// Rejestracja komend
const registerCommands = async () => {
const commands = client.commands.map(command => command.data.toJSON());
const rest = new REST({ version: '10' }).setToken(config.token);
try {
console.log('Rejestruję komendy...');
await rest.put(
Routes.applicationGuildCommands(config.clientId, config.guildId),
{ body: commands }
);
console.log('Komendy zostały zarejestrowane.');
} catch (error) {
console.error('Błąd rejestracji komend:', error);
}
};
// Event: Bot gotowy
client.once('ready', () => {
console.log(Zalogowano jako ${client.user.tag}
);
registerCommands();
});
// Event: Obsługa interakcji
client.on('interactionCreate', async interaction => {
const command = client.commands.get(interaction.commandName);
try {
if (interaction.isCommand() && command) {
await command.execute(interaction);
} else if (!interaction.isCommand() && command?.onInteraction) {
await command.onInteraction(interaction);
}
} catch (error) {
console.error(error);
if (interaction.replied || interaction.deferred) {
await interaction.followUp({ content: 'Wystąpił błąd podczas przetwarzania interakcji!', ephemeral: true });
} else {
await interaction.reply({ content: 'Wystąpił błąd podczas przetwarzania interakcji!', ephemeral: true });
}
}
});
// Logowanie bota
client.login(config.token);9 replies
DIAdiscord.js - Imagine an app
•Created by kermiot $ on 11/17/2024 in #djs-questions
selectmenu dont working
see the code ticket.js how and index.js I added interactions and still nothing
ticket.js
9 replies