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

130
Views
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 answers
Answer question

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 Report
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!