Coding Your Own Discord Bot - Discord.js - Creating a Scrim Team

Coding Your Own Discord Bot – Discord.js – Creating a Scrim Team



Views:9558|Rating:4.83|View Time:19:53Minutes|Likes:117|Dislikes:4
Help to support the channel if you are feeling super kind:

Join our Discord:

In this tutorial I teach you how make create the basics of a team system where you can add members and reset the current team as well as printing the current team to the channel.
———————————————————————————————————–
If you liked the video then please respond with a like and a subscribe to show your support for the channel and I’ll repay you by creating more tutorials like this one 🙂

okay so hello and welcome back to another JavaScript bot tutorial and this one I'm gonna be covering a kind of a request because I'm citing two requests now someone was basically wondering how to do a kind of team picker so like you can have the bot story like lineup of teams like a two teams and then you can assign captains and pick members and then you know that'll sort that all out so that well basically what we're gonna make is we're gonna have a way to store ten people then a way to pick two captains and then those two captains can then pick the players for each team so we'll end up with basically two lists where we have the members and the captains or I guess by that point the captains doesn't really matter this will probably a two-part video because I well I'll be a two-part video it will be okay obviously if you have any more ideas for these disco bot tutorials there you know what you want to make your bot do because obviously it's good practice to try and make it yourself but I understand that some of this it's quite complicated and get your mind around it so if you have any specific requests and they're not too difficult I mean even if they are difficult I'll still think about it and figure it out because before these tutorials I basically think how I would do it make it test it make sure it works and then you know do the video on it so I'm not sitting here struggling thinking during the video same with one my videos as well stop see over unison whatever you've got any ideas leave them in the kansai have a text file of plenty of ideas to keep me going for a while but it's always nice to keep hearing more and obviously if you want then you know show you support that'd be lovely just probably jump into the video on discord I have been kind of asked by the programmers valley disco server i've been added as a member and i use the discord quite often we have different channels for all the different languages it's kind of like my server but quite a big you get you've got more people and here more professionals as well my servers more of a kind of you come for help this is like the same but we've also a lot more people that know what they're on about and it's just generally more active you know because they've got more members I would recommend joining this and obviously as well as mine I'll put the link to both in the description if you want to join you know it's just something to be part of the community but anyway let's get into it sooo I might actually keep discard window ready then I'm gonna be using it for this video so let's just minimize it there and turn off the bottom ok so first of all the request is you know make some way of storing members now there's only me in the server so I can just store me multiple times but when you make it you'll probably want to have a way of being like so the same guy can't join twice now let's say you have a team and you play a game and you want to start again you're gonna want to reset so we're gonna first of all create the simple command which is going to be a way of resetting your list so let's just add a new group here called what's call it teen these can be team related commands so we'll add team and then we will create a new folder called team and our first command we're gonna call it new underscore team J's so this is also going to be the command for starting the team afresh it's gonna be a really to command to be honest we're gonna chuck this in and do a few tweaks so we're gonna call it new team command now we'll call the command or just do exclamation mark new team I'll just keep it all lowercase a new team let me just check just coin flip I don't think any of my other things even have nice fun and scribe fine I'll do new and it's got to you you can do the commands whatever you want and what to say you know traits a new team whatever okay now we're going to wipe this because I should copy that from the other one and we'll just call will say we're going to explore the command so it's available to be used so what all we let you want to do is we want to have a list and this this function here is just gonna reset reset the list now let's say you had a list like far but there's your list if you wanted to set it if you wanted to basically wipe the list and start again you would literally just you know presumably you've declared it somewhere else you would just say well the list is now equal to this which means a blank list but we need a list and this list is going to be accessed from multiple scripts and we could have like really awkward ways of passing the list around and probably do something wrong some get lost so the easiest way is go to the go to the head script the you know main box script and we'll just make a global variable which is accessed by all of the scripts in the modules so if we say the low bold dot and then we think of name so we'll call it like current team members equals you know empty list if we just write current team members in any of our scripts it's gonna refer to this list so it's now globally accessible the downside to this is we can't ever make another variable in our thing called current team members but we hopefully should never have to if you do then enough so you have to think about that so that's global current team members so if we go into here and we say was it current team members equals blank that is literally gonna just take it and blank it and we can then say you know message dot reply the current team has been set and then we'll just go node oops no oh did that work by the dot I don't think it worked no it's not work because it's not said ready yeah okay no I can type no it's face.com ready okay we'll bring up the bot and we'll say was it new team new I'm Scott team the current team has been reset now see we don't have any proof over being reset so we can I'll show you that when we actually get to it now we need to actually create a way of joining a team so as you might expect we're going to create another team command so we're gonna create new file join underscore team Jas we'll take a new team and I'll pop in it and we'll just quickly change a few things so this is going to be a jointing pan this command is basically instead of making the making the command and then you putting in parameters for the people you want to join we'll just have it so that the person who wants to start it all off cause this command this might be only accessible by people of a certain role that's it I need to make certain commands accessible better roles that can be covered in next video as well to be honest and then anyone else in the server that can join whether that requires a role and itís up to you will do this of a command that's joint command and it'll add them because remember we pass in a message here which we can also refer to the person who sent it so we can add people to the list without even having to put in their names that the button knows who it is so if we do join Team Command and we'll just put you know a new team will just put join underscore team this needs to be team did I not do that in the other one sorry if you forgot in C as well team team okay join team will say joins the or team yeah okay now what's it going to do well assuming you know anything about lists let's say you've used Python you would do a list name dot append and you put in a value to put on the end of the list the way to do appending in javascript is called push and then you have pop to take something lvls push and pop sounds much more fun than append and remove in Python so what we know is we're going to say well let me just remember what it's called current team members so I'll say current team members dot push and we pass in something so we're going to add the message author now the good thing about message to offer is it's not just the person's name as a string it's actually all the info about the person so it's gonna have their ID and all these other things and if you have someone's ID it means you can refer to them in the server rather than just their name because if you refer to someone's name and try and access them back let's say for example I don't know maybe they've changed their name or the nicknamed or something and it's gonna cause problems so having their ideas like they're solid you know it's like the DNA they can't change their ID as far as I know unless you make a new account or something stupid like that so basically what this does now is whenever we call join team it's going to add the person who called it to the team and then to be honest what we'll do is well we'll go back to the main thing and what was have another message command one that was I don't here will say like Elsa because this doesn't need to get run if they put hello because it's not going to be hello if messaged on 10th is equal to let's say they say I don't know what's that I'll fix this what's their current team and okay the reason why we're getting this problem is because this is closing the string here but what you can quite neatly do is you can just do this thank you it's going to treat it as a string stole because that's a different string character to this string character that's the benefit having Beach marks in quotations so we're saying if that's the thing they put in I'm it's quite a long thing that you never know you could change it to be what you want well then print so we're going to say a message dot channel what we're gonna say message channel dot send and we'll send in the current team members now what we'll do is we will say like let's just do this so assuming after nailing right there's no errors okay good that's a good start so you know we'll make sure the team's reset even though every time you restart the bot it will be will say you know new team let's reset we'll say join team and then if we now say why don't make this such a long thing we're just saying what's the current team stop a dino and then let's say we then join it again because we're someone else we'll pretend that would someone else join team Weprin it again it's to defer dinos obviously if we had everyone do you know join team with other names so join them to our team and then during underscore team this is now adding us to the list and what's gonna print the whole list and this has reference to the person yes it is adding them you could just get it to print the string even you're storing them but you could actually just get it to print the string so if this is the author its doctored username I'll see the problem is it's sending the list you would have to loop through the list so let's say what one cool way I'm gonna one in the next video when I continue this we're going to send it as a rich embed just like I showed in the video where we create these custom things we could have two rows and the two rows could be the two teams and we could have like team one team two you know down here we could even have an option for the captains to choose their team names and so on we could you can just extend this to be as complicated as you want just have like a cool bot system how long is this video over 12 minutes should I cover anything else in this video what I will cover is I'll show you this looping thing maybe well no yeah I'll show you the leaping thing as an embed for now so what we'll do is if you go to the info about me show we see we didn't embed sorry embed so if we get this into here so we'll say team info equals this just like in the info thing and then we'll do all these things all do dot set title I just need to remember I'm doing this race yeah that's a title then we'll say what would the title be so title can say like current team members and then we don't want to underscore again what else do you want to set about it we could do we could add fields we could set colors whatever you can even have a from now obviously as I said like do whatever will say I wonder if inside here we can do a loop let's see if we can we'll say for int no sorry this isn't this is for VAR i equals 0 I is less than current team members dot length count notice that its length in this increase i and then i'll say dot set tide tall no not set out the do set field so we're going to add a new field for each person so dot set field and we're going to pass in current team members i wherever we are in the list now it's saying it something a problem because it's a it needs to be here so how we're going to loop because we're inside the variable here kind of like setting that so what we'll do is we'll take this out of the thing and we'll say team info dot set field actually work and then at the end of this whole thing we then need to do you know message channel that send our team info and this was obviously if something I didn't expect to add so if I've done it wrong I've not had time to approach this one practice make sure what you should work at it's your I wouldn't so if we go to discord and we'll say you know join team join team will do it three times so this is for your phone people joining pretend and then we'll say the stupid you know what's the current do you get problems it's saying that discord is not defined in the new discord rich in bed oh I didn't actually okay so if you look in here we actually added discord ivory whereas this which used this court yeah okay now just me forgetting a library I should just have that in there anyway to be honest there's no harm in it I don't think I'm less certain things overlap but we'll see no dot alright let me just do this most copy and paste with my trusted join Team 1919 what's the current Dean my problems dot set feel there's not a thing it's odd field why am I being an idiot this is what happens when you don't prepare for a particular part in a video that's why I wanted to end it early because I'd done all this other stuff in preparation and yeah I hadn't done this one to free what's their current team well this just showing you're debugging you know oh yeah so what it's actually doing is it's it is adding all the members but it's adding their weight it's just printing you can't add someone inside an embed so if we do i dot username let's have a quick look at it i don't matter if the video drugs on a little bit longer that's not too long you can stick around you can try and figure this out if you you want on your own I'm just thinking of a cool way to do this so our free people joining what's the current team there we go it's saying undefined under it and I'm wondering why says undefined why is there like another text field under it anyway this adding field I don't think it usually Oh because I didn't actually yeah okay basically when you do a yeah I wonder if I can just set it to blank I'm sure I can if you go to the thing it takes in a second parameter for on the field it takes in a second parameter so just we'll just say wait blank maybe I assume that work unless you actually do want to put something that you could say member one member to member three and so on I said this is painful to do one two three and then what's their current team you can't actually have the value empty let me go and check why down there in the mirror and the info sorry so we have string there's a title string as a description true or to say member name I've got I've got idea we'll move this and we'll put that afterwards and we'll say member plus I dot two string I just have a look at to see how this works I am currently just messing around to be honest just to try and make it look good I'm just gonna add myself twice to be honest now there we go officer yet also one of the thing is to remember list start from zero so we would just say you know I plus 1 dot 2 string okay I think that's a video done that's pretty good so far I think so we're gonna you know join join join join quite a few times and we're gonna so what's apparent team there is it's currently dapper Dino Dino Dino and DAPA Dino vs. no one and then just to prove that it works we'll say new team and then we'll say what's the current team it's empty so there you go that is this video done I'm probably halfway there to get in this whole system working at the base things therefore it would have to do some tweaking and one more thing really yeah so even if you weren't looking for this video in particular I hope you enjoyed it and it might have taught you something about just using disco but in general all these tutorials should help you obviously yeah if you want any specific requests and just ask show support on these videos by leaving a like and subscribe that I'd love that a lot thanks for sticking around for these past 20 minutes thanks for watching and good bye

20 Replies to “Coding Your Own Discord Bot – Discord.js – Creating a Scrim Team”

  1. Зем Юра

    TypeError: Cannot read property 'username' of undefined

    HELP ME I DID EVERYTHING LIKE HERE AND THIS STILL POPS UP AAA

  2. LowKah

    could you make something that will make it so there is different ranks and it puts every one automatically in a rank depending on their wins on fortnite ?? just so scrims are based on skill.

  3. Bill Papadodemas

    @Dapper Dino – Coding Tutorials As some previous guys mentioned before there is a huge need over the Scrim bot on Fortnite. The bot obtain the 3 last digits of the server the players join. There is a specific chat where the bot acts and segregates teams with the same 3digit code. Are you able to make something like that, i am pretty sure that a lot of people are asking for it.There is a whole community here in Greece who are waiting for an evolution in our server like this. Plz let me know if are able to contribute… 🙂

  4. Cool Tube

    I got a error saying:

    (node:31312) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'map' of null
    at CommandMessage.run (C:UserscarolynDesktopdunbotnode_modulesdiscord.js-commandosrccommandsmessage.js:230:28) at <anonymous>
    at runMicrotasksCallback (internal/process/next_tick.js:121:5)
    at _combinedTickCallback (internal/process/next_tick.js:131:7)
    at process._tickCallback (internal/process/next_tick.js:180:9)
    (node:31312) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 8)

  5. Junghoon Yoon

    Thank you for the video! Always appreciate the guidance. I was wondering if you could just briefly discuss the leave channel command. Should I have message.guild.voiceConnection == message.guild.user for the disconnect to only work if the user and the bot are in the same guild? I'm pretty new so I guess I'm lost there haha.

Leave a Reply

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