#Need help with module exports

1 messages · Page 1 of 1 (latest)

quasi jewel
#

I want to convert my code to be suitable for module exports

code:

    client.on('guildCreate', guild => {//new server
  const channel = client.channels.cache.get("801476479380095026")
  let Embed = new EmbedBuilder()
  .setAuthor({name: client.user.username , iconURL: client.user.avatarURL()})
  .setColor(0x90EE90)
  .setDescription(`> ${client.user.username} has **Joined** a new Server 🎉
**ServerName:** ${guild.name}
**GuildOwner:** ${guild.owner}
**ServerID:** ${guild.id}
**GuildsCount:** ${client.guilds.cache.size}`);
channel.send({ embeds: [Embed]})
});

  client.on('guildDelete', guild => {//leave server
    const channel = client.channels.cache.get("801476479380095026")
      let Embed = new EmbedBuilder()
  .setAuthor({name: client.user.username , iconURL: client.user.avatarURL()})
  .setColor(0xff2a26)
  .setDescription(`> ${client.user.username} has **Leave** from a new Server 💔
**ServerName:** ${guild.name}
**GuildOwner:** ${guild.owner}
**ServerID:** ${guild.id}
**GuildsCount:** ${client.guilds.cache.size} `);
channel.send({ embeds: [Embed]})
  });
zealous whale
quasi jewel
#

I already read them but I'm dumb with docs I can't understand them

zealous whale
#

okay, but no one here is going to write code for you - so you have to understand them

quasi jewel
#

client.on('guildCreate', guild => {
}

Just want to know how to convert these

zealous whale
#

and that you will know if you read the guide, it's explained there with examples

quasi jewel
#

is this right ? @zealous whale

#

sorry for the ping

quasi jewel
#

What is the command that make them run

winter chasm
#

someone already said to put it in 2 separate files

quasi jewel
#

what should i put in the bot.js file to make them work

winter chasm
#

its in one file still

quasi jewel
zealous whale
#

again, the guide covers this so please stop asking the same over and over without trying first

quasi jewel
#

no

#

i mean what should i put in the index.js

winter chasm
#

your events also need to be in separate files if you have an event handler

quasi jewel
#

the code is not running

zealous whale
#

and I'm saying it's covered in the guide linked about separate event files

quasi jewel
#

Its very confusing im really a newbie

#

u know what nvm thx

winter chasm
#

its kinda in the rules....

quasi jewel
#

I know