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

135
Visualizações
Detecting when a text channel is created by another bot with discord.js

I'm pretty new to javascript or discord.js but my guess was something like this:

client.on('channelCreate', channel =>
{
    message.channel.send('test');
})

I'm guessing 'channelCreate' doesn't exist.

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

0

Your guess is right.

According to the discord.js documentation, you can listen to a channelCreate event to trigger something when a channel is created.

To know who created a channel, your bot need to access the audit logs and the first entry of it.

client.on("channelCreate", async (channel) => {
  if (!channel.guild) return;

  // Fetch the audit logs of CHANNEL_CREATE events.
  const audit_logs = await channel.guild.fetchAuditLogs({
    limit: 1,
    type: "CHANNEL_CREATE"
  });

  if (!audit_logs.entries.first()) {
    console.error("No entry found.");
    return;
  }

  const entry = audit_logs.entries.first();
  const executor = entry.executor;

  // The executor property is type User,
  // so you can easily check if it's a bot by doing...
  const is_bot = executor.bot;

  // `is_bot` will be boolean.
});

Resources

  • https://discord.js.org/#/docs/discord.js/13.7.0/class/Guild?scrollTo=fetchAuditLogs
  • https://discord.js.org/#/docs/discord.js/13.7.0/class/GuildAuditLogsEntry?scrollTo=executor
  • https://discord.js.org/#/docs/discord.js/13.7.0/class/User?scrollTo=bot
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