How do I make my bot automatically create the channels and roles required for my bot to work as soon as it joins a server?

144
September 01, 2021, at 01:30 AM

So I do know how to make my bot create a role and a channel. But what is the event called when my bot is added to a server? thats all I want to know (the event name when my bot joins a server) I tried searching up in the documentations of discord.js but only got .createdAt and .createdTimestamp which will just give me the time when the guild was created.

Answer 1

The emitted event is guildCreate. This provides the guild joined as the first, and only parameter. Your code should be like this:

client.on("guildCreate", async (guild) => {
  //guild is an instance of Guild which the client has joined
})
Rent Charter Buses Company
READ ALSO
How can I update Text column that represents JSON in MySQL

How can I update Text column that represents JSON in MySQL

I have a column (TEXT) which stores json textI need to update the data

122
how to change the result of a map by another format React

how to change the result of a map by another format React

I would like to explain my problem of the day

114
data attributes in a bootstrap-table data table causes an infinite loops

data attributes in a bootstrap-table data table causes an infinite loops

I'm trying to output data in a table using bootstrap-tableIt outputs the data, but causes an infinite loop while saying "loading, please wait"

143
Get all the indexes from the array on matching the condition

Get all the indexes from the array on matching the condition

I have int array which is returned from preparedStatement as below:

113