Kick & Ban Command | Discord.js v12 tutorials

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello guys welcome back to another video today in this video what we're going to be doing is we're going to be making our your kick and band command so sorry i haven't been uploading lately i just got a job and i'm also next week i will not be uploading any videos because of i'm going to be going on a trip and yeah so let's get straight into this on our last video i believe what we did is we made a help command with the the travel fast travel links and all that so let's get started so in our commands file or folder you want to make a file and you we're just going to start off with the kick command so we're just going to name it kick dot js now here what you want to do is you want to come over here you can copy one of your previous commands paste into your kick and you can delete the message the action inside of it now for this the minorities need to be one max arcs needs to be one also activation sneak can be whatever you want i'm just going to name it kick this is a kick command now this our permissions is going to be kick members now i'm going to quickly copy that paste in here you can also choose any other one you want from here as you can see if i'm correct kik members is one yep it's right here you can copy it you can paste it right here it doesn't matter so now the first thing you want to do is you want to do const sup or it so it doesn't have to be sub i'm just gonna actually let's name it author so we know what we're talking about equals message dot author now this is gonna go to whoever sends message is gonna get their user tag now we're gonna do const user so the first mention so we need to do equals message dot first no dot mentions dot users dot first then we're gonna do our parentheses now this is just saying the very first person that is mentioned in the message for instance if we do our kick command kick and then we're just gonna do let's say we're kicking me it would only take the first hat so yeah now what we need to do is we need to make it to where if the author or the person who sent the message messages asks themself it does not say oh you have been successfully kicked and you're not actually kicked or you can it won't kick that person because i know i had that problem previously so we're just gonna do a statement so we're gonna do if parentheses is author equals three signs user then we're going to come out here to brackets and inside the brackets we're going to do message dot channel does send then we're going to do our quotation marks i'm going to do you cannot kick yourself now out of here it doesn't you can go out of here now we're going to do an if another statement for user then we can get all that brackets inside the brackets we want to do const member equals message dot guild dots member then we're going to put user instead of here now basically what this is saying is if the user is inside the guild it will successfully do it now what you want to do is you want to go down the line you want to do an another if statement so if now we want to do member in here then you want to put more brackets then we're going to put member right here enter one more time then you want to do dot kick and then you want to do parentheses then you want to do args dot splice if i can spell it correctly then you want to do our brackets we're going to put one inside of there now you want to do join brackets parentheses no not parentheses quotation marks then space inside now that's going to kick it kick that user now we want to do a dot then statement parentheses parenthesis inside now in the first set of parentheses you want to do an arrow function and then you want to do a bracket like that now after this what you want to do is you want this is going to say once the member is kicked it will send a message message so we're going to do message dot reply parentheses or backtick right next to our one now we want to do our message so i'm just gonna do successfully kicked now i'm gonna mention the person that got kicked so we're gonna do our dollar sign brackets no it's not gonna add them it is going to get their user id then it's going to get the tag so user.tag there now you want to come down here to a catch statement just in case there isn't something going on it cannot kick the member so we're going to do error inside of these parentheses and then you want to do a narrow function now you want to do brackets now instead of here you want to do message dot reply parentheses and then just are quotation marks i am i cannot kick that member now we can come down to this bracket we can do an else statement now inside of here we want to do a message dot reply then we'll do our quotation marks we're going to do that user is sent in this guild now this is just if this doesn't work so let's say the member isn't in the guild it's going to come down here and send this now you want to do another else statement instead of here down one more bracket now inside of this you want to do our quotation marks again not yeah hold on mess up a bit so right inside of it you want to do message dot reply quotation marks you did not mention the user to kick and then there our kick command is done so we can easily just copy this for our band command i want to make another file inside i recom another yeah another file inside our commands folder namedband.js based in there we can simply rename this to ban ban this would just be ban members and you can find out inside your command base permissions you need band members now what you want to do for this is instead of the remember no we're keeping the member and stuff but right here we're going to quickly format this so it's a bit easier to read so instead of kick it's going to be banned now what you want to do here you want to come in here you want to put our brackets for this then you want to enter before args enter after the quotation marks all right so we get a issue right here it's because we need our comma and then it's not inside of here we need to do reason all right instead of our reason what we need to do is we need to put our two colons and then there quickly what else we need to do is we need to highlight this and just do our put brack a our parentheses then there now you can actually put a reason so here we just want to get rid of max rx since there's going to be reason min args can be 2 since you just one keep it up one now you can change this to successfully banned i cannot ban and then this user isn't building to ban now i believe that is it so let's try this out so we're gonna quickly save our kick and bam now terminal we're gonna clear we're gonna do node space dot now we want to come into our discord go into our testing server and we're just going to try it out my friend since he's online so we're going to quickly run through all of our message.reply let me quickly get them back online we're going to do kick nope sorry i'm used to using my other bots so i'm all right so we got something going on here so let's quickly look so ban ban okay so now we go to our kick make sure did we use banner kick all right we just kicked so something went on with kick so let me quickly find out what i did wrong and i'll be right back with you okay guys so i'm back so basically what happened is i forgot that i put this the min args to zero that needs to one it needs to be a zero because then we cannot fully run our tests so now we can clear terminal restart it make sure you change those now we're denied we're gonna do kick there then we're gonna do ban now we're gonna do kick we're gonna at myself all right so you cannot kick yourself i cannot kick that member so it's going to send those both since you cannot kick yourself and you cannot kick yeah now we're going to ban a viper so me myself all right so there's that so let me quickly go get my all so i'll be right back okay i got my test account in here so we're gonna run um kick our test account there and then it's successfully kicked so i'm gonna quickly invite it back there it is now we're gonna do explain ban code viper now it's successfully banned and whenever i try to will come back in it will not work because i am banned so later on in the future i'll make an unban command as you can see he's banned well my alt is banned so i'm going to quickly revoke it and then i'm going to invite my alts back then as you can see it worked so that is all for today i hope you guys have a great fourth of july and i'll see you guys next time bye
Info
Channel: CodeViper
Views: 11
Rating: undefined out of 5
Keywords:
Id: tUP0R9QfLJQ
Channel Id: undefined
Length: 12min 15sec (735 seconds)
Published: Sat Jul 03 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.