Discord Bot in C# Tutorial - PUG/Elo Bot - [1] Up and Running

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
[Music] guys welcome to the first video in a series where i teach you how to make a discord bot in c-sharp uh pretty cool language um this is kind of a beginner to intermediate more intermediate course but you can follow along and i do all the coding there with you and i give you a template to work with too in the start so that's pretty cool and um yeah we're going to be more specifically talking about making a pickup game or pug bot so you'll be able to organize matches and custom lobbies with your friends and your server discord server and uh and it'll it'll spit out like what map to play what the teams are all that fun stuff so um why don't we get into it guys go ahead and open up your browser and what the first thing i'm going to do is make the bot so you can discord developer portal you're going to search that in google find the first link it should look something like this you want to go to your applications at the top left and you're going to create a new application i believe i have too many made so give me one second here i'm gonna have to delete one all right guys i'm back sorry about that i just deleted one of these programs these are all applications within discord or more specifically usually they're just bots discord bots as you can see we have ones for like fraggers which is a rogue company pickup game server that i've created with a friend and a couple other people are owning it as well and we also have a cpl pugs which i helped develop the bot in javascript i'll show you these servers real quick so i can show you what a pug bot is really um basically if you there's a q channel right and it looks something like this where all the players are queuing up and you would click this reaction and join the queue it says six out of eight players needed for the game and then when it pops um that match just got reported so it was done uh when the cue pops or the queue is full it makes a match channel and all this fun stuff and it goes ahead and makes your match so you know what what map you're playing who's on your team and whatnot this is a crossfire server as well i'm part of and it's very active right now it's dead because it's mostly eu based so it's getting kind of late but this server has a lot of matches played in the last month and whatnot too so there's a crossfire and rogue company a little background about myself so let's go back to this application page and we'll get started go ahead and click new application at the top right name it whatever you want i'm going to call it my pug bot okay and now you can do some fun stuff we can add pictures so i'll go ahead and add a picture of myself here because my pug butt this is for the tutorial on youtube okay and it immediately when you create this and save it oh sorry i thought it froze uh it has a client id you're going to want to keep track of that i'll tell you in a second you have a secret you don't need to worry about this too much a public key and some other stuff but this is basically your application within discord what we want to do is make it a bot application so you go over on the left hand side it says bought and you're going to add bot and it says and then you say yes to it so it's irreversible that's okay so now we've made it a bot and that what that means it gives us a bot token we need this so we're just going to hold on to this for now this page and what we're going to do is set up a server and discord here so i'm going to go into my server listings i'm going to click the plus sign i'm going to create a new server for me and my friends and i'll call it dirt server for now it sounds pretty good here's a general server that's this is what it looks like when you first create a server and discord before you invite all your friends and right now there's no bot running if i run the ping command there's no one in the it's only me and the server so what i want to do is first invite this bot to the server it'll be offline but that's okay we're going to go over to oauth2 on the on the discord developer portal make sure we're selected the mypugbot app or whatever you call it and you want to check the pl the checkbox for it under the scopes it's a bot and the bot permissions we want to give it administrator okay and that changes this link a little bit when you click these two boxes so then click copy open up a new tab paste it in there and this is all it takes to add a bot to a server right you go you find your server you authorize it so it's going to be dirt server and you're going to continue you want to give it granted administrative privileges click yes i am a human i'm a human and there we go you can x out of that now and look at that my pug bot is in the server but it's offline so we want to get this bad boy running all right so what we're going to do now is um get the code right so we need to i have this on github i put this base template out for a discord bot and it's in c sharp and it has some if you're if you're kind of advanced c sharp has some cool functionalities we're using dependency injection uh if you're familiar with discord.net it's using the command structures and we're we pull our settings from a json file sensitive information and and just regular information as well so this is this is kind of cool basically i'm going to give you the link in the description below all you're going to do is click on code you're going to go to download zip and save it and what we're going to do is go to our downloads folder and where is it here i'm going to cop i'm going to copy this this zip file and put it on my desktop sorry it's so messy but we're going to put it somewhere down here where you can see it here's the zip file and then what you want to do is i'm going to rename it to tutorial is we're going to right click it extract extract here and it it made a little folder for me okay so here it is here's the folder it extracted all the files in here you see we have this vs folder is useless you can kind of delete that probably um but we have what we have is a is a solution file and we have all the the template in here as well so if you don't have visual studio code i mean visual studio not the code version you want the visual studio so you're going to write it in c sharp you're going to want to download the 2019 version or the latest version okay we're working with 2019 so you just double click the solution file to start it up or to uh open up the coding and we get this window this kind of look here connects out of some of this alerts and uh you can look through all the the structure of the spot we have commands so we have these generic this generic class which holds generic commands okay so we have this command called ping which will check whether the bot is working or not okay a little just reply to the channel pong pretty easy i can say pong tutorial is down okay so we can do something like that i can change it up models has nothing in it so that's why there's an x there in pug service this is just a blank service and i'll show you how to add services and whatnot that we we want that will help um will help our bot out you know some services that we want this is a pug service we'll fill this in later um you have bot settings so in this bot settings we're going to be noting that we want the token the id of the bot and the prefix of the bot so what is the prefix if i go back to my server here the prefix is that what starts the command in your text and irc here it'll be the exclamation point so the exclamation point is actually the prefix we have channel settings and emote game settings um oh i did fill in some of this to get you started you can like select the team size the name of the game that we're playing we have role settings and stuff like that so these are all settings and basically usually they're just ids or just constant values that you want to keep throughout your program so example for channel settings we might have a welcome channel and it'll be a yulong that's the type you don't have to worry about it so you write public you long welcome channel id and then you put these properties these getters and setters like that with the curly braces and then what we do is go over to our app settings.json this is where you're going to be putting in the stuff and i know it's getting complex already but don't worry about it under role settings this is how you add settings we would have one called welcome channel id and we will put that to uh say we made a welcome channel right uh welcome uh i'll teach you how to get the the this id thing you can right click and copy id if you have developer mode enabled i should show you right now because that's actually really important so we would just set it like that in the app settings and we put all our settings into this app settings.json that's what i meant by pulling it from a json file okay and program you don't have to worry about all this magic right now or even the worker service associated with it you don't have to worry about any of this we're going to be working more with commands services settings etc either way i'll show you how to get developer mode enabled on discord it's really important what you want to do is go into user settings and go to appearance and at the bottom it says developer mode under advanced appearance and you just enable that and what that's going to do is it allows you to say like i can copy the id of a message i can copy the id of a person i can copy the id of a lot of different stuff of a channel so you can get the ids and all ids they're snowflakes or big numbers in discord everything has an id and so they're all organized and categorized by these big long numbers and so that's what i mean by ids when i reference ids on certain stuff identification stuff okay so basically i'm going to show you how to i already showed you how to get to download it you you follow the link in the description download the zip extract the zip and make sure you have visual studio installed and um yeah we'll go on to the next segment here hey guys i'm back uh we're on the next segment here but before we start i just want to say if i work too fast or talk too fast i'm sorry uh this is to try to get as much information out as possible because there's a lot going on when building any type of application and what i want to do is not cater so much to people who are struggling with that with the speed at which i talk because on youtube you can rewind and come back and stop it and whatnot so just try to you know if you have questions about certain stuff definitely leave it in the uh in the comments below tell me what you like what you don't like and we'll we'll adjust the videos as we go from here because this is day one this is 12 24 then x-mas x-max eve christmas eve just got off work and i'm excited to begin this series so um yeah let's get into it we'll go back so we were at the code here trying to think of the next step so again this is the app settings.json file it has oh let's insert the token and the id of the bot and we can change the prefix as well if we want excuse me all right so go back to your browser go back to that developer portal what we're going to do is get the token and that's under bot copy your token you can reveal it and copy it to and i'm going to change this at the end of the video here's i'll change it every video so that nobody none of you elite hackers can steal my stuff and you just put it in between these quotation marks okay a quotation mark is a string in both javascript and in uh this is javascript object notation so that's what json means but um it's a it's a quotation mark if you see stuff in a quotation mark it means it's a string which is like a word honestly a big long word or it can be multiple words like whatever it was spaces in between but anything in it in quotation marks is a string and the id is going to be a number that big long number that's a you long so go back to general information about our app and we want our client id you can copy that and just paste it in there without quotation marks should look something like that and that's the idea of my bot okay and then the prefix is there so if you want to change this to like an equal sign anything that's one character long it could be a period it could be a uh whatever that thing is we're going to keep it as exclamation point for the purposes of this tutorial and to run it in debug mode there's better ways to run it but you can just click this once you've inserted the token and the id you can just click this green button here and hopefully fingers crossed it's going to start it up as a worker service which means it actually when our bot loses connection it actually reconnects which is pretty cool so anyways now our if you go back to your server listings my pugba is online and guess what chet you betcha you guessed it if i do exclamation point ping tutorial is dope our bot is running on our server and all we had to do is download some like you know some sketchy code no i'm kidding so all we had to do was download uh the template i made insert the id of your new discord application and the and the token and it runs it and we have a command here already called ping now if i do like something like non-existent existent uh nothing happens so we can figure out how to have some sort of parser where it will it'll tell you hey that command doesn't exist or whatever and delete the message but for now we just have we have some commands here oh we have one so to end it you just x out of the program and it's going to go back offline okay all right now let's go on to the next segment actually no i think that's going to wrap up this video number one guys in the next segment we're gonna start filling out the pug service we're gonna be doing cool stuff like adding a list of users in the queue uh we're gonna be adding a join command to join the queue and all this fun stuff all right so stay tuned guys head on over to the next video
Info
Channel: The Derd Show
Views: 1,123
Rating: undefined out of 5
Keywords:
Id: QLP_ocNKrQg
Channel Id: undefined
Length: 14min 31sec (871 seconds)
Published: Mon Jan 11 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.