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

140
Visualizações
Discord.js sending message in a specified channel using a command handler btw

I am trying to make the code in this video where it sends messages to different channels but when I do destination.send(“message”), it says that destination is not defined when I define it in the line above let destination = client.channels.fetch('11223344556677');

My code is:

const Discord = require("discord.js");
const client = new Discord.Client({ intents: ["GUILDS", "GUILD_MESSAGES", "GUILD_MESSAGE_REACTIONS"], partials: ["MESSAGE"] });
module.exports = {
    name: "stop",
    description: "this stops the server!",
    execute(message, args) {
        if (message.member.roles.cache.has("112233445566778899")) {
            let destination = client.channels.fetch("112233445566778899");
            if (destination) {
                destination.send("stop");
            }
        }
    }, //else {
    //message.channel.send("I see you don't have the correct permissions");
};
//}

client.login("112233445566778899");

what I am trying to do is have a command !stop where it sends stop into a channel with the channel id.

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

I think channels.fetch is not working in your discord.js version. Try my code below:

const Discord = require("discord.js");
const client = new Discord.Client({ intents: ["GUILDS", "GUILD_MESSAGES", "GUILD_MESSAGE_REACTIONS"], partials: ["MESSAGE"] });
module.exports = {
    name: "stop",
    description: "this stops the server!",
    execute(message, args) {
        if (message.member.roles.cache.has("role_id")) {
            let destination = client.channels.cache.get("channel_id");
            if (destination) {
                destination.send("stop");
            }
        }
    },
};

client.login("bot_token");
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