Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

206
Visualizações
Why is my kick command only giving errors?

Wassup people. I am working on some admin commands. At this moment it's going to be a kick command. But it's only giving errors. If you remove a line or change anything, it will infect the code in another place.

That's what I am struggling with.

Here's my code:

const { Client, Intents } = require("discord.js");
const discord = require("discord.js");
const { MessageEmbed, Collection, Permissions } = require("discord.js");

module.exports = {
    name: "kick",
    description: "Kicks a specific member",
    admin: true,
    usage: "[Target] [Reason] [Messages]",
    options: [
        {
            name: "Target",
            description: "Provide A User To Kick.",
            type: "USER",
            required: true,
        },
        {
            name: "Reason",
            description: "Provide A Reason For The Kick.",
            type: "STRING",
            required: true,
        },
    ],

    async execute(message, args, client) {
        const target = message.mentions.members.first();
        const reason = args.slice(1, args.length - 1).join(" ");

        console.log("Target: ");

        const embed = new MessageEmbed().setTitle("There seems to be a error to execute this command").setColor("RED").setDescription("Are you sure you got the right permission? And are you providing a reason?");

        if (!message.member.permissions.has(Permissions.FLAGS.KICK_MEMBERS))
            return message.reply({ embeds: [embed] }).catch((err) => {
                console.log(err);
            });

        if (target.id === message.member.id)
            return message.reply({
                embeds: [new MessageEmbed().setTitle("There seems to be a error to execute this command").setColor("RED").setDescription("Why would you kick yourself?")],
                ephemeral: true,
            });

        if (target.permissions.has(Permissions.FLAGS.KICK_MEMBERS)) {
            return message.reply({
                embeds: [new MessageEmbed().setColor("RED").setDescription("You can't kick this person.")],
            });
        }

        const DMEmbed = new MessageEmbed().setTitle(`You've Been Kicked From ${message.guild.name}`).setColor("RED").setTimestamp().addFields(
            {
                name: "Reason:",
                value: reason,
            },
            {
                name: "Kicked By:",
                value: message.member.user.toString(),
            }
        );

        await target
            .send({
                embeds: [DMEmbed],
            })
            .catch((err) => {
                console.log(err);
            });
    },
};
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

From what I can see, it is most likely the reason field being empty.

You can change it to this to ensure there is a fallback!

            {
                name: "Reason:",
                value: reason.replace(/\s/g, '') == "" ? "Not Provided" : reason,
            },
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda