How to make a Discord bot in 5 minutes! - Node JSDiscord is one in every of the most popular. social platforms mainly for players with. hundreds of thousands of channels that use bots for. one-of-a-kind functions. it has to paintings 24 7. for this we positioned it. inside. our own cloud server we assign a sequence. of permissions. after which we invite it to our discord. server. when we do that do that the bot is going. to begin listening for various routine. and those activities can be as an instance whilst. someone sends a message in a channel. or while somebody new comes into the. server. for that reason i'll use discord.js. yet there's also discord.pi. discord.php and a gaggle of other. libraries that you'll be able to use for this. let's initiate via going to discord.com. developers. login and create a brand new software. i will name it but enter flash. let's add an icon and. shop changes then we'll go to. https://wefx.info/mom-bot-discord-click-here/ and add a new bot. we're going to replica the token that this. is going to give us due to the fact we're going. to apply it later to authenticate. now create a brand new folder and iin this. folder on your terminal. run mpm init to begin the npm. task i will go away this. empty but you may move ahead and fill it. out. then we're gonna run npm install. discord.js. and that is gonna install the discord.js. library in our task. ultimately i'm going to create an index.js. file and. open this folder in my editor. so now let's open the index file. and in here we are gonna get the client. from. the discord.js library like this so. we're gonna require. discord.js. and we're gonna initialize the customer. then from this client we'll get. the ready event so. unready and we're going to run this. function. that's simply going to be a console.log.that asserts. logged in as user tag so let's. get it from the client.consumer.tag. then we will add the customer.login. with. our token right here but i don't need to place. the token. correct within the code i want to placed it. external of the code. in an environment file so we'll. create a new file. name it emv and in here. we're gonna create a variable with the. token we copied before from the. web page web page now this file is not. gonna be. uploaded to my github repo but i am gonna. create a new one which is gonna be known as. emv.example and this one i'll add. it. due to the fact this shouldn't have my. token in there it is just going to have. the empty variable. now so as to not add my emv file. to my github repo i will create a. dot get ignore. file and put my dot emv dossier. in here just type it in and that is it.Now with https://wefx.info/matchmaker-discord-bot-see-here/ keep we are able to cross ahead and. run npm. set up dot emv this kit. goes to allow us to get the. variables from the dot emv. dossier into our javascript code. we need to require the kit and then. initialize it with the config. variable now after we do that. we will now use the variable from the. token. by using doing approach dot emv dot and the. call of the variable which is. discord but token now to check this out. we are able to run. node index and as you can find. the bot runs in fact now going back to. the internet site. let's move into oauth select bot. then for permissions we are going gonna. decide upon ship messages and browse message. historical past. and we are gonna copy the hyperlink to invite. the discord bot. now we are gonna move forward and entry this. link and invite it. on your server. there is the permissions and i'm gonna. click on. accept on all of these.Now as you will discover the bot is already. going for walks in my server. and we'll add a couple actions. to them. let's start by way of including yet another event this. goes to be the. on message event so on message we are. going to run. this operate which receives the. parameter message. now first we're gonna cut up the contents. of this message. with the aid of spaces so every note in an array. and we will investigate if the message. starts offevolved with. our command that's going to be enter. flash like this so the 1st word. is input flash then it means it's caught. into. the bot we are gonna get the second. be aware in the message and if this moment. note. does not exist we are just gonna return. and nothing is gonna occur but in case. the second note in the message exists. we are gonna investigate what that note. is and in case the be aware is howdy. we're additionally gonna positioned it in lowercase.<iframe src="https://www.youtube.com/embed/vQw8cFfZPx0" width="560" height="315" frameborder="0" allowfullscreen></iframe>


トップ   編集 凍結 差分 バックアップ 添付 複製 名前変更 リロード   新規 一覧 単語検索 最終更新   ヘルプ   最終更新のRSS
Last-modified: 2022-01-19 (水) 01:29:01 (818d)