Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

169
Vistas
Cannot read properties of undefined (reading 'send') (Discord.js v13)

i have been trying to make a leaveserver code for my bot, but i always get the error message Cannot read properties of undefined (reading 'send') I really wanna know why it always says the error messages! Please help me! Thanks!

const Discord = require("discord.js")
const rgx = /^(?:<@!?)?(\d+)>?$/;

var self = this

const OWNER_ID = require("../../config.json").OWNER_ID;
module.exports = {
  name: "leaveserver",
  description: "leavs a server",
  run: async (client, message, args) => {
    if (!OWNER_ID)
      return message.channel.send("This command is Owner Only")},
      
async run(message, args) {
    const guildId = args[0];
    if (!rgx.test(guildId))
    return message.channel.send("Please Provide a valid server id!")
    const guild = message.client.guild.cache.get(guildId);
    if (!guild) return message.channel.send(message, 0, 'Unable to find server, please check the provided ID');
    await guild.leave();
    const embed = new MessageEmbed()
      .setTitle('Leave Guild')
      .setDescription(`I have successfully left **${guild.name}**.`)
      .setFooter(message.member.displayName,  message.author.displayAvatarURL({ dynamic: true }))
      .setTimestamp()
      .setColor(message.guild.me.displayHexColor);
    message.channel.send({embeds: [embed]});
  } 
}

about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

Try this code

const {
    MessageEmbed
} = require("discord.js")
const rgx = /^(?:<@!?)?(\d+)>?$/;
const OWNER_ID = require("../../config.json").OWNER_ID;

module.exports = {
    name: "leaveserver",
    description: "leaves a server",
    run: async (client, message, args) => {
        const guildId = args[0];
        const guild = message.client.guilds.cache.get(guildId);

        if (!OWNER_ID) return message.channel.send("This command is Owner Only");

        if (!rgx.test(guildId)) return message.channel.send("Please Provide a valid server id!")
        if (!guild) return message.channel.send(message, 0, 'Unable to find server, please check the provided ID');

        await guild.leave();
        
        const embed = new MessageEmbed()
            .setTitle('Leave Guild')
            .setDescription(`I have successfully left **${guild.name}**.`)
            .setFooter({
                text: message.member.displayName,
                iconURL: message.author.displayAvatarURL({
                    dynamic: true
                })
            })
            .setTimestamp()
            .setColor(message.guild.me.displayHexColor)
        message.channel.send({
            embeds: [embed]
        })
    }
}

Removed the duplicated async run(message, args) {

about 4 years ago · Juan Pablo Isaza Denunciar

0

Try to do this:

const client = new Discord.Client({intents:
["GUILDS", "GUILD_MESSAGES"]});

client.on("message" , msg => {

   await guild.leave();
    const embed = new MessageEmbed()
      .setTitle('Leave Guild')
      .setDescription(`I have successfully left **${guild.name}**.`)
      .setFooter(msg.member.displayName,  msg.author.displayAvatarURL({ dynamic: true }))
      .setTimestamp()
      .setColor(msg.guild.me.displayHexColor);
    msg.channel.send({embeds: [embed]});
})
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda