[TRAIN WHISTLE]
OK, that was the sound effect this time
for my substitute train whistle.
Welcome back.
You came back.
That's so nice of you.
I'm here in the second video in my
How to Make a Discord Bot series.
I actually was just recording this,
but I had a technical problem, so I'm doing this again.
But that means I'm going to be perfect.
I'm not going to make any mistakes.
Very rarely happens, I mean I will make lots of mistakes.
So where do you need to be doing now?
The first thing where I want to get started in this video
is I want to make the Discord bot itself.
I'm going to need to do that through the Discord website.
So go to Discord.com.
Make sure you're signed up with an account
and you're logged in.
You can scroll all the way down to the bottom
and look for where it says Developers.
So if I click here, I am now in the Discord Developer portal.
So there's lots of information here.
I encourage you to read it through, take a look
at this stuff, read about all the possibilities
and the polices.
But what I want to do here is go under Applications.
You can see here I've made several applications already.
I've been making Discord bots for a little while now.
I have a bot that I made for the ITPIMA program.
That's the department that I teach
at at NYU School of the Arts.
I have a dad bot which will tell you dad jokes.
It's dormant right now.
I've got to revive that one.
And then two other example bots for different courses
that I've been teaching here at NYU.
So it's time now for us to make our coding train bot.
So I'm going to click New Application.
Are you a game dev?
Oh, my goodness, this is such a deep philosophical question.
I'm not a game dev.
I am going to name my application Coding Train Bot,
and I'm going to call it Application here.
This is a little bit silly, but this
is-- there's a difference between the application
and the bot itself, which I will get to.
That will become evident as I go a little further through this
here.
So I'm going to hit Create.
I want to have a neat icon.
I actually spent like a half an hour
earlier trying to pick which icon.
And I'm just going to go straight to it now--
rainbow hearts.
Can't go wrong with rainbow hearts.
And then look, I've got some important information here.
I've got a client ID.
This number is really important.
I'm going to make use of that in just a moment in order
to add the bot to a particular Discord server.
I also have the client secret.
This is a secret key that you absolutely should not
show to anybody else.
For example, I really, really definitely should not right now
hit Click to reveal.
Ahhh!
All of you will not be able to hack my account,
because if you do this by accident,
it's not the end of the world.
I can very quickly just hit Regenerate
and I've got a new one that you also see.
Don't worry.
Later, before you watch this, I'll have regenerated it.
The client secret actually isn't something
that I'm going to use at all in this video series.
The client secret is a code that you
need if you were making a Discord integration from a game
or some other broader context.
And all I'm doing is making a bot.
And I want to talk to the Discord API from my bot.
For that, I need something else called a bot token.
So let's move on to that next stage,
and I'm going to go down here.
So even though I've made the application,
I have not made the bot itself.
So I want to look over here and find Bot.
Click there.
I don't have a bot yet, but I can get one.
Let's add a bot.
Yes, do it.
The username will just be-- let's call it Choo Choo Bot.
This here, this token that I'm about to reveal to you,
this is something that I will need for the code.
And also, this is something I'm really
going to have to think about.
If I'm putting this token in the code,
and then I open source my project so you
can use this as an example, I want
to make sure that I don't include the token in that.
So I will address that later on as I get to future videos,
but for right now, I just want to make note of that.
And I'll be coming back to that in the next video.
We're almost there.
I've got my Discord account.
I've made my client application.
And now I attached a bot to that particular application.
The next thing I want to do is make
this bot a member of the Coding Train Discord server itself.
To do that, I need to go back to General Information,
and I need to grab this client ID.
Once I have the client ID copied into my clipboard,
I can paste it into this URL path--
discord.com/oaut h2/authorize?cli
ent_id=YOUR_CLIENT_ID--
I'm going to paste it right in here.
And this now is a particular URL that you
could embed into a website or send to anybody
if you wanted them to add your bot to a particular server.
And this brings up an important question about trust, right?
In this case, right now, I am the maker of the bot
and I am the owner of the Discord server
to which I'm going to add that bot.
So I am just trusting myself.
And I think it's going to be OK.
But if somebody were to send you a link to their bot
and say, please add this to your server,
or if you're just asking people willy nilly, please add my bot,
please add my bot, there's trust that has to happen there.
Bots have a lot of permissions and things
they could do in a server, and could really wreak havoc.
So this is something I'm going to have to think about.
How do I vet people's creative bots
that they make to include into the server?
Maybe I'll come up with a process for that someday.
But most likely, if you're going to take this next step,
you might not have permissions right now
to add a bot to any server you're a member of.
So you might need to create your own Discord server first.
When you're logged into Discord, you'll see a plus button,
Add a Server.
That's the place you could start to create your own server
for testing your bot.
But for me, I'm just going to take this particular URL,
open up a new tab and paste it in, and hit Enter.
And now, here we are.
Coding Train Bot Application, Connect to Discord.
It's going to give me a list of servers where I have
the manage server permission.
So I have the manage server permission for these servers.
I want to add it to Coding Train Choo Choo.
I'm going to click Authorize.
It's very exciting.
All right, and then I'm going to click--
but, but I am a robot!
I'm a bot!
I'm a robot!
What do I do?
As a human being, I am the maker of the bot,
so I guess I can click this, I'm not a robot.
And it's authorized.
Let's head over to the Coding Train Discord server.
I can actually quickly check the passenger log.
That's a channel that whenever a new user joins,
a message is posted there.
And look what we've got at the bottom here,
welcome aboard Choo Choo Bot.
Choo Choo bot better read that code of conduct.
And Choo Choo bot has hopped into the server.
So I know that the bot is there and I
am ready for the next step.
I'm going to head over to a channel called Bot Testing.
This is the channel that I'm going to use
for working with the bot.
Eventually, I might let the bot run rampant all over the server
itself and all the other channels.
But as I'm figuring out and getting the basics working,
I want to stay in this channel.
Let's just mention it to make sure it's really there.
There it is.
Hi.
So at some point, I could certainly, from the code, see,
did somebody mention the bot, did mention me?
And then reply appropriately.
So that's what I'll be getting into next.
We were there.
We've now made-- have a Discord account,
made a Discord application, added a bot
to that application, and then authorized that bot
on a particular Discord server.
If we've done all of that, we are ready for the next step,
actually writing some code to connect to the Discord
API itself, and have that bot communicate and participate
in the Discord community.
And that'll be fun.
I can't wait.
I'm going to go do that now.
And I'll see you there if you want.
That's what I said last time in the last video.
Where's the whistle?
[TRAIN WHISTLE]
[MUSIC PLAYING]