Make Your Own Discord Bot | Commands (NEW 2019)

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
ladies in German welcome back to another video in this video my teach you guys how to make custom discord commands using discord as a yes once again this is a serious in my channel where I go through the basics on how to get started making a discord but using discord IGS last episode I went over the specifics the specific basics on how to get your butt running how to out your bought into I want to open that how to get your bought into your own private discord channel and how to get your bought running with the token and everything else so if you're new here and you don't know where and how to get started there'll be a link in description go ahead and check out the first video where I go over the basics on how to get started in this episode I'm gonna go into detail about commands more about specific commands and how to you know how people can interact with your bot another thing again if this is not gonna be a series where I go from beginning to end from easy to hard there's gonna be a series where I go through the basics and then after getting down with the basics I'm gonna go ahead and start making specific bot specific cool BOTS that you guys like for example I might do the tour and how to make it a league of legends spots or how to make a four-night bot or how to make something that you guys would like so in the comments below I want to Hue hear your opinions and your what you want me to do with the upcoming videos any suggestions about what discord BOTS I should be creating with that let's just get ahead let's just go ahead and get started with our video again last video we created our discord bot with node and then PN and discord LJ yes and note that G is they'll be a link in the description to beyond that if you want to go ahead and go check it out if we open up a project we left off here where we created a simple command this was just a test command to see if our bot was running all you did was say hello and he bought responded hello friend so let's get started so the first thing we need is we need a prefix every command that anybody has usually has a symbol at the beginning that indicates that the you know the thing that they're typing is meant for a command for a specific bots most people usually use an exclamation mark or a question mark or a money sign a money sign mark whatever you like we're gonna go ahead and create once I'm gonna do a constant do Const once again it's constant the variable cannot be changed one named is prefix and it's gonna be equal to just a string and for our prefix we are just going to Dupre what did I do wrong here cons prefix okay I don't know what was happening there there was an error that seemed to happen there without no excuse all right we create a constant if you don't want to do a Const into a variable and change that later but we're gonna create a constant cons prefix equals and this is gonna be your little symbol at the beginning of the command all right so we're actually gonna delete this because we don't need this actually we need this first part where it says bought that on message because this is gonna be basically listening to our bot with the message so we're gonna keep this here the other thing we need is we actually go to make another variable I'm going to call their arguments I'm actually not doing it let if you guys know about programming let's it's like a constant which is basically a variable but if you guys might do more research go ahead and do that we're gonna do a let our eggs and it's gonna be equal to a message I'm actually change this these the MSG here to a message because I'm actually used to doing message so message not content so I do substring and went do a substring of the prefix I'm gonna do dot length and I'm gonna do a dot two splits and then we're gonna split it up with little quotation marks here and then a space and I'm gonna do that that's basically gonna allow us just to implement the prefix at the beginning of our arguments the next one to do is going to a switch a switch is basically a an if statement it's just easier to do if you're doing multiple commands so before we had an if statement here we're are actually abused to a switch so when you switch and we're gonna do arguments oryx I'm gonna leave this open because I'll explain what this means in a bit and then we're just going to open up the switch statements so the arguments this is a quick little programming lesson here I'm gonna put 0 here what does this mean the RX 0 means that if the first basically the first word after prefix is gonna be our X 0 in programming arrays are from zero to a specific number so for our first arguments if we want to do you know our prefix and I'm gonna do something like ping this is our first argument if we're gonna do another argument after that let's just say ping and our second argument is help this will be argument number one so if you want to do something about this you would come here and do argument one but we're doing argument zero because that's the first literal argument that we have at the beginning then we'll do a case and then this is gonna be basically ping this is the same thing as equals equals ping if we had a like an if statement and when opened up with a semicolon and then we're gonna do a message that reply and then we're just gonna do pong and we're gonna break it here we have to break it and then that is basically our or command here if we actually go ahead and run the bot we do this and no other space dots if you don't know how to open up the terminal go back and check my last video let me go back here and our bot is on line and if we do school measured point paying the bot Charice wish to reply with pong now a lot of people may be asking so how do I like how do I change this where the bot will not respond to a specific person but we're just sent pong in the channel most of the commands in bots they're not meant for a specific person there's just the bot sensitive to a channel so what you can do here is recloser a bot ctrl C to close it we change this from message to reply to message that channel that send message and then we do palm let's open up terminal no or space dots and bodies on line we go back in here we do ping and it's just gonna respond pong without replying to a specific person that's typing it all right so let's continue let's just go ahead and create another command so we're gonna do another case so we're just gonna do actually that's just for body a little better case and then this is gonna be let's just say web sites let me do a message that channel that send message and we're gonna send that our web sites for this I'm just gonna do my gaming YouTube channel if you guys wanna subscribe to maybe a YouTube channel there'll be a link in description ha see there's a little quick little advertisement there and we're gonna break it so that's just gonna be if the first argument is website alright let's continue so case let's just do something like info most of our things usually have an information so we're gonna open this case and then I'm gonna do a message actually let's let me teach you about what if you want a second argument so case info and what if the if let's just say that if for info you must have a second argument which would be and the array would be number one so we would want something like info version something like that so we do case info then we do an if statement so if the arguments the second argument which will be of course number 1 is equal to version then we want to message that channel that had send message and I would just type version here version 1.0 or something like that it doesn't matter and then we're gonna do an else so else else if there is no argument if if someone does something like let's just say he does info and then he does info author or something if you don't specifically make a command for author we're gonna reply message that message that channel that said message and we're gonna respond invalid arcs or invalid arguments and then of course we're gonna break the case so we're gonna break and just like that if we open up the terminal the terminal know it's crazy dot and we go back into our discord let me do info and that's gonna be invalid arguments because we didn't specify what we wanted the info for so we do info and then we can do version and it's gonna show us version one point zero point one and you can actually create over here like a variable if you want to like change your version often a variable let's just a version version and then it's just gonna be a little bit you know tidy things up like this and then you can just come over here and then just do version and if we actually just close this and open it up again it should work I'm just teaching you guys if you want be a little bit more organized so info version they should do a version oh well we should we should probably do you sorry a version if you want to have the version the word version before the actual version you open up a string version then you do plus and in the actual version which is still very what we have up here so let's just close this info and just like that version and sexually there should be space right here space there you go that fixes everything alright so let's just do a cool command let's just get into a little bit more of you know detail stuff let's just say we want to command to clear a certain amount of of messages in a specific channel now we actually haven't gotten into permissions I might I think next videos gonna be about permissions but permissions will allow you know specific commands for specific perms through specific permissions specific so you know so people can't just randomly join a channel and then start deleting stuff and stuff like that if you're creating like a really heavy and admin bot it's very important to have permissions but we don't have permissions yet but let's just go ahead you know that's just let's go ahead and just do is okay so we're gonna create another case and this is gonna be clear open this up and then for this first is we're gonna make sure that there is always gonna be a second argument or as in the programming term a first argument or argument blend that there are always to be a second argument for this to work if we don't have this we're gonna get a bunch of errors so let's just do it so we're doing if we're do our x1 so if they are not so I should have to do an exclamation mark if there are no second arguments we're just going to return should we turn a message to whoever sent it so reply and we're gonna do error please define second argh something like that just to hold them out and I'm gonna go over here and we're gonna begin so we have new message it's actually very simple to do a delete message that channel that bulk delete and then we're gonna do our arguments the first arguments and that's basically it and when a break of course so let me just organize my my code here so this let's just let me just run through what I just did here so we created another command then we did is that if the command of the second the second argument in the command does not exist return a message to the whoever sent the message err please define a second argument if so continue message the bulk delete the certain amount of commands or comments the amount of comments that they want to delete so if we continue here look that I've finished downloading note dots and we run our bot if you go over here and then we do clear it's gonna be sorry error please define second argument and we do clear space five good take awhile and it's gonna delete five of the messages so let's just doing to do clear 10 it's gonna go ahead and delete the whole thing and it's gonna clear the chat so this is basically how commands work you get a lot a lot of stuff done with commands that's basically how most people are going to communicate with your BOTS using these commands so you can go ahead and start messing around with commands through your own specific commands they are actually a lot a lot of helpful tools and like communities and forms that will help you create your custom commands so if you wanna do something specific you can go ahead and just search how to do it I will leave the disc radhaji is Doc's down below in the description click on that that will run through a whole lot of things you can do with commands and just implement them change them around edit the numbers and stuff like that but this is basically it in general how to do disk or BOTS it's just like this we are gonna get a little bit more advanced because as you can see we're just replying messages and right here we have little advanced where we're deleting specific messages but in the future we're gonna be creating a lot in a lot of more complicated BOTS we're gonna be you know you know getting into how to communicate with other servers how to communicate with net how to retrieve stuff and a lot more stuff so this is it for the video we basically threw into the box we created all the commands you can go ahead and mess around you can get you know get started doing a lot of stuff but for now this is the basics and how to create a custom command on with using this without J S on your own personal discord bots so with that being said thank you guys for watching I hope you guys enjoyed this video once again I want you guys to go into the comments below and comment any suggestions for the upcoming videos I'm almost getting ready to finish with the basics even though I only have two videos I only have to get out like I think like a permissions and like embeds and stuff like that and just after those videos we're gonna get started into the real juicy how to create specific discord BOTS and that's what's gonna get a lot of fun and you guys are gonna help me out on creating your own specific BOTS and your you know the bots that you guys would recommend me to create so I hope you guys enjoy this video please subscribe to my gaming youtube channel they'll be a link in the description also subscribe to this youtube channel if you want to see more coding videos and how to create more discord bots and yeah so hope you guys enjoyed and I will see you guys later on my next video peace
Info
Channel: CodeLyon
Views: 356,797
Rating: undefined out of 5
Keywords: discord bot development, make your own discord bot, discord developer, discord.js, discord bot tutorial, code your own discord bot, discord app tutorial, code discord bot, program your own discord bot, how to make a discord bot, discord js commands, discord bot custom commands, custom discord commands, how to make discord commands, how to make discord custom commands, discord command development, discord command tutorial, coding discord command
Id: OQsUnFDT7iE
Channel Id: undefined
Length: 16min 32sec (992 seconds)
Published: Mon Feb 04 2019
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.