Discord JS - Welcome Message Bot

broken image

Receiving that information very well so first. we'll. open up vs code or whatsoever identification you are. using and we will check out our. discord.js bot. project that we simply created in the last. video if you already have a discord bot. that is okay and we're gonna cross ahead and. create a new file and we're gonna call. this welcome.js. and right under our config file right here. we are just gonna create a variable. called welcome and we are gonna set it. equal to require.welcome. all right now that we have that let's pass. forward and truly utilize. that variable so we're going to say. welcome and then right here we will. circulate in our customers. now we will move in our purchaser. right here due to the fact we will correctly. want to use that. purchaser inside of this separate js file. so we'll say. module dot equals client. which is our client that we're passing.

broken image

ship a invite to our checking out account. here. say invitations let me cross forward and replica. this hyperlink here after which i'm just going. to join it on. our testing account right here now we will see. that a trying out account got added to. the discord server let's go ahead and. investigate our console to work out if we have our. person and it seems like we do. let's take a look at what we got here we have. their identity their username. even if their bot their range identification all. that great things so sincerely we will see. that this guild member ad. event is truly firing and has. efficiently. logged our member to the console however. let's have a. committed channel for welcome messages. so that manner our widespread channel is not. stuffed up so let's pass forward and create a. text channel here. we'll name this welcome and. then let's visit our server settings. here. and let's move forward and uncheck ship a.

Random welcome message when someone. joins a server. due to the fact we don't desire the two discord's. automated message method. and our customized one to be sending. messages simultaneously let's go forward. and save that. and now we're in fact going to must. get the id of this channel. and the way we can actually get that identity. is by going to the arrival tab. in your discord settings and you're. going to need to allow developer mode. in this type we can actually right click. our channel. here welcome and we can actually get a. replica  identity. alternative and with that copy identity option we. can actually store that. right here so let's pass forward and shop that in. a variable we're going to say const. channel id and we're going to set it. equal to. our identity of our welcome channel like so. now that we have got our channel identity let's cross. forward and create our customized message so.

we will say const. message and we're going to set our const. message equal to backticks after which. we're going to say. welcome and here's where we'll. desire to enter their custom username so. with a view to get their username we are. going to use a few one of a kind break out. characters right here so we're going to do. a below sign and at sign and then. we'll do a dollar signal. two curly braces we will say. member dot identification. after which we're gonna do a more than. sign here to close that off and we are going to. say welcome. username to our server and now that we. have that we're gonna need to get. our channel so we're gonna say const. channel and set it equal to. member dot guild we are gonna get the. channels from our guild we're gonna get. the cache. and then here is in which we could do dot. get and enter our channel.

discord scheduling bot  which we created up right here that is the. identity of our welcome. channel and then we are gonna say channel. dot ship. and our message here so let's move ahead. and try this out and see if it really works so. we're going to say node. index to start up our bot i will. go forward and kick. that trying out account after which we are. going to reinvite that checking out account. and now that i rejoined our testing. account. we are able to see in our welcome channel right here. on our discord server. welcome da trying out account to our server. and as you can see our message became sent. by using the bot that we created here and genuine. quick earlier than we end this video i simply. want to show you how. we can tag an extra channel so if we want. to direct them to a guidelines channel we are able to. let's move forward and create that channel. real fast so we will say rules. and we will ought to get this identification.

Of this channel so back. right click on reproduction identification and we're going to. say const rules. channel and we will set it equivalent. to the identification that we just grabbed and then. at the tip of our message right here we are. going to claim. ensure to take a look at our after which we're. going to do greenback signal. curly braces member dot guild then we're. going to get our channels. our cache dot receives and we're going to. get that rules. channel variable that we simply created. then we'll say dot to. string that allows you to convert that to a. string so it appears pleasant in our message. and now let's cross ahead and really. restart our bot here we'll say. node index. over again i will kick our testing. account right here and reinvite it and now. once we return to our welcome channel. we are able to see welcome da testing account to. our server ensure to check out our.