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

610
Views
Error - TypeError: client.on is not a function (Discord.js)

I get this error:

Client.on("guildCreate", (guild) => {       
TypeError: Client.on is not a function

My code is:

const client = require("../index");
const { MessageEmbed } = require("discord.js");

client.on("guildCreate", (guild) => {
    let channelToSend;

    guild.channels.cache.forEach((channel) => {
        if (

            channel.type === "text" &&
            !channelToSend &&
            channel.permissionsFor(guild.me).has("SEND_MESSAGES")

        ) channelToSend = channel;
    });

    if(!channelToSend) return;

    channelToSend.send(
        new MessageEmbed()
            .setAuthor(guild.name, guild.iconURL({ dynamic: true }))
            .setDescription("Thanks for inviting me my prefix is '?'")
            .setColor("RANDOM")
            .setTimestamp()

    )


});
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You are not creating the client correctly.

The official documentation said to do that for creating the client:

const { Client } = require('discord.js');
const client = new Client({ intents: [Intents.FLAGS.GUILDS] });
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!