a way to make a Discord bot in 5 minutes! - osu bot discord is one in all the hottest. social structures chiefly for players with. hundreds of thousands of channels that use bots for. different functions. it has to work 24 7. for this we put it. within. our possess cloud server we assign a chain. of permissions. and then we invite it to our discord. server. when we do that try this the bot goes. to start listening for different movements. and these routine could be for instance when. someone sends a message in a channel. or when someone new comes into the. server. thus i will use discord.js. but there's also discord.pi. discord.php and a group of different. libraries that you'll use for this. let's start up by going to discord.com. builders. login and create a brand new program. i'll call it yet input flash. let's upload an icon and. save adjustments then we'll go to.
bot de musica discord and upload a new bot. we will reproduction the token that this. goes to offer us because we are going. to use it later to authenticate. now create a new folder and iin this. folder on your terminal. run mpm init to begin the npm. assignment i will depart this. empty but you could move forward and fill it. out. then we are gonna run npm install. discord.js. and it is gonna install the discord.js. library in our task. ultimately i'm going to create an index.js. dossier and. open this folder in my editor. so now let's open the index file. and in right here we're gonna get the customer. from. the discord.js library like this so. we are gonna require. discord.js. and we are gonna initialize the customer. then from this client we're going to get. the all set event so. unready and we're going to run this. operate. that's simply going to be a console.log.
how to host a discord bot announces. logged in as consumer tag so let's. get it from the customer.user.tag. then we'll add the client.login. with. our token here yet i don't need to place. the token. correct in the code i want to placed it. outside of the code. in an atmosphere dossier so we'll. create a brand new file. name it emv and in right here. we're gonna create a variable with the. token we copied before from the. internet site internet site now this dossier isn't. gonna be. uploaded to my github repo yet i am gonna. create a brand new one that is gonna be called. emv.example and this one i'll add. it. because this won't have my. token in there it is simply going to have. the empty variable. now with a view to now not upload my emv dossier. to my github repo i'm going to create a. dot get ignore. file and put my dot emv file. in here just kind it in and that's it.
Now with discord crypto bot keep we can pass forward and. run npm. set up dot emv this package. is going to allow us to get the. variables from the dot emv. file into our javascript code. we need to require the package after which. initialize it with the config. variable now once we do this. we will now use the variable from the. token. with the aid of doing technique dot emv dot and the. name of the variable that's. discord but token now to test this out. we are able to run. node index and as you will see. the bot runs in fact now going again to. the web page. let's go into oauth choose bot. then for permissions we're going gonna. choose send messages and browse message. history. and we're gonna copy the link to ask. the discord bot. now we are gonna go forward and access this. link and invite it. to your server. there's the permissions and i am gonna. click on. receive on all of these.