Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

291
Views
TypeError: no se pueden leer las propiedades de undefined (leyendo 'destruir')

me sale este error:

TypeError: no se pueden leer las propiedades de undefined (leyendo 'destruir')

Al ejecutar este código:

 const { SlashCommandBuilder } = require("@discordjs/builders"); require('dotenv').config() module.exports = { data: new SlashCommandBuilder() .setName("restart") .setDescription("Restarts the bot."), async execute(interaction, args, client) { let isBotOwner = interaction.user.id == '847213179142799452'; if (isBotOwner) { interaction.reply('Restarting...').then(m => { client.destroy().then(() => { client.login(process.env.TOKEN); }); }); } else { interaction.reply('You cannot run this command unless you are the developer of me.') } } }

El error está en client.destroy() . He estado buscando en los documentos y guías y en Google, pero no puedo encontrar nada sobre cómo hacer que funcione.

¿Podría ser porque estoy tratando de destruir el cliente a través de un comando de barra?

Aquí está el controlador de comando/interacción:

 const { Client, Collection, Intents } = require('discord.js'); const client = new Client({ intents: [Intents.FLAGS.GUILDS] }); const fs = require('fs'); require('dotenv').config() client.commands = new Collection(); const commandFiles = fs.readdirSync('./commands').filter(file => file.endsWith('.js')); for (const file of commandFiles) { const command = require(`./commands/${file}`); // Set a new item in the Collection // With the key as the command name and the value as the exported module client.commands.set(command.data.name, command); } 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 }); } });
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!