Easily Code a Discord Bot: Side 1 – Constructing
hiya men what’s going on welcome to the. first episode of my discord bot academic. during this academic we will basically simply. be getting the code mounted and a bot. jogging it won’t always do whatever. yet but I’m just going to reveal you the way. to set up the bot account using the new. discord bot method so pass ahead and visit. the discord web site make sure you’re. logged into the browser in your account. and you’re also going to need to install. a visible Studio there is a loose edition. if you simply click right here the down load will. start and you’ll install it and simply. use each of the default settings so when you. have visible Studio established and walking. should look like this you are going to. desire to setup a bot account so that you can do. that you’ll visit discord app comm scale down. developers and over into my functions. you could create a new program call it.
whatsoever you desire those functions can. be used to create to create many things. other than BOTS but due to the fact we want to use. this as I bought click this button right. right here which will create that will cause. this application to be a bot so now cross. ahead and replica this code i am just going. to head ahead and open notepad and just. shop that for later and now the last. component we need to do is upload our bot to. our server and so you will need to possess a. server or have manage server / missing. persons so as a way to add a bot on your. server they really intend to make this. less difficult but when you go to you’re still in. the developer’s web site below oath . BOTS copy this URL right here this complete. issue let’s move ahead and paste that in. the notepad. and this wide variety right here that’s just. the big wide variety delete that and update. it with this variety so purchaser Identity equals.
dice discord bot and it truly is the quantity in your bot. so then you are taking that aand paste it up. right here and it’ll allow you to upload your. bot for your server increase and as you could. see the bot is now in the server so. congrat an X out of all thiis now that we. have the bot in our server we are able to get. into the code like I suggested we are simply. doing the very fundamentals we are unlikely to. do too much simply past getting it up. and going for walks so let’s create a console. software visual csharp windows. console application and call it disco. bot and iin order to so we’re going to be. utilizing the discord net library to create. the spot and iin order to add that to. this task visit equipment NuGet package. manager deal with NuGet applications ensure. that is set to all after which you can sort. in here the rectangular web and truly add. minimize and you may set up discord web as.


good as discord web instructions. so now that that is carried out we’re ultimately. able to write code let’s cross ahead and X. out of that and back ordinarily application. in the subsequent academic I’m going to variety. of do an overview of the way this code works. if you know then you definately can skip. that yet for now just pass ahead and sort. what I variety get it as close as you may. otherwise it won’t work alright. and then let’s create a brand new code file. rightclick on Disko bot upload class and. it’s going to be my bot received to make certain. this is equal to what you typed here. and this often is the code for our bot so. let’s create the constructor right here and. before we can begin utilizing the discord. the decoded from the discord library we. need to include it in this file using. discord and using discord dot commands. awesome. so let’s correctly positioned this up right here just.
Above the general public my blot my bot and. we’ll add some logging. functionality so it’ll tell us when it. connects or if there’s an error or. something. X dot log level equals log severity that. info famous person log handler let’s log and. that’s going to be an error so we’ll. outline that in a minute correctly let’s. do that now. private log okay so various this code. isn’t fascinating it is not any. time you write a discord bot it’s going. to be a similar code time and again. so that’s why I’m not likely explaining. it an excessive amount of yet when we get added into. into the tutorials i will do plenty. more explaining on what what things do. and how you should use them to just do. what you desire so this hooked up the logging. now we will make the bot attach. and it truly is the part in which we are going. to go back and get some token information so.
rss bot discord and wait a sync and. then we will say oh wait discord. dot connect and now with a view to attach. previously we had to apply a username and. password but now with the recent mounted we. just use the token which we are able to get from. discord comm curb builders and cross. lower back to my software and iit’s not this. one it is that this one here click on to. show so this token is a mystery in case you. provide it to somebody accidently then they. can log in as your bot and that’s no longer. well so do not show it to persons after. you do that the bot ought to paintings so let’s. cross forward and pull up discord and primary. let’s see the bot is offline and we run. this and the bot comes on line and this. actually pulled up over right here that’s the. bot itself so you will discover it linked. and it says guild available dev server. that’s this server that I had on the.

Bot to. so that’s tremendous one final thing we are able to do. is simply add a really simple command simply. to show to prove that it works so in. order to do this say discord dot using. commands institution see X dot prefix care and. so this is going to be the that you. write before the command to tell the bot. that it is a command I like to use. exclamation points many people use. the tilde you need to use whatever you want. and you also can say X dot allow mention. prefix equals true so meaning you may. like if you have a command that says. mute you could say mute and it does the. command or you can say at disco bot. and then it is getting messed up due to the fact. i am attempting to write in the code yet you. outlined the bot after which your command. comes after that aalright in order that units up. the instructions allow us to create our first. command this line gets the command.
provider so that way we are able to begin. registering commands we are just going to. create a really simple command command. set create command hey and then whilst. you execute that command let’s do this. continues trying to vicinity. and so once you whilst the person calls. the command hey it will do the. code that we positioned right here and iit’s going to. supply us lots of information about the. command in E as a way to say e dot channel. that’s the channel that the command was. given in so that they can say channel dot ship. message hello so when someone uses the. hiya command it just says hi and it’s. going to give this error until you assert. oh wait after which that’ll all solve so. now if we run the bot see here it’s. going for walks if we open discord you can say. hiya and it says hi or we are able to point out. the bot and say good day and it executes. stew command ok so that’s it for this.


Leave a Reply

Your email address will not be published. Required fields are marked *