title
Create a Discord Bot With Node.js
description
Let's create a Discord bot using Node.js (JavaScript)
Anson The Developer YouTube:
https://www.youtube.com/channel/UCvjXo25nY-WMCTEXZZb0xsw
Code:
https://github.com/ansonfoong/discordjs-bot-starter
💖 Support The Channel!
http://www.patreon.com/traversymedia
Website & Brad Traversy Udemy Course Links:
https://www.traversymedia.com
Follow Traversy Media:
https://www.twitter.com/traversymedia
https://www.instagram.com/traversymedia
https://www.facebook.com/traversymedia
Timestamps:
0:00 - Introduction
1:16 - Project Setup
4:36 - Creating Discord Application
8:06 - Adding the Bot to our Discord Server
10:46 - Logging the bot In
15:36 - Basic Events
18:26 - Ready Event
20:56 - Message Events
25:06 - Bot Responses
30:31 - Basic Chat Commands
37:36 - Kick Command
52:54 - Ban Command
1:00:45 - Message Reactions & Reaction Roles
1:12:15 - Webhooks
1:17:09 - Thank You
detail
{'title': 'Create a Discord Bot With Node.js', 'heatmap': [{'end': 522.263, 'start': 462.205, 'weight': 0.82}, {'end': 839.494, 'start': 788.434, 'weight': 1}], 'summary': 'Tutorial series covers creating a discord bot with javascript and node.js, detailing bot setup, management, handling messages, setting up text commands, member management, banning users, and integrating webhooks, emphasizing the use of discord.js library and object-oriented programming.', 'chapters': [{'end': 203.459, 'segs': [{'end': 36.439, 'src': 'embed', 'start': 7.045, 'weight': 2, 'content': [{'end': 7.765, 'text': "Hey, what's going on, guys?", 'start': 7.045, 'duration': 0.72}, {'end': 13.627, 'text': "my name is Anson and today I'm going to be teaching you guys how to create a very simple Discord bot with no JSON JavaScript.", 'start': 7.765, 'duration': 5.862}, {'end': 21.11, 'text': 'Now, before I even get started, I want to thank Brad Traversi for this amazing opportunity to be on his channel to teach his viewers, you guys,', 'start': 14.228, 'duration': 6.882}, {'end': 22.491, 'text': 'on how to create a Discord bot.', 'start': 21.11, 'duration': 1.381}, {'end': 28.453, 'text': "His videos have helped many programmers including myself, and I can't thank him enough for all the work he's done for the programming community.", 'start': 22.571, 'duration': 5.882}, {'end': 32.536, 'text': 'With all that being said, I also do have my own YouTube channel where I post on a regular basis.', 'start': 28.553, 'duration': 3.983}, {'end': 36.439, 'text': 'I post videos ranging from server-side development to front-end development.', 'start': 32.636, 'duration': 3.803}], 'summary': 'Anson teaches creating discord bot without json javascript, thanking brad traversi and promoting his own youtube channel.', 'duration': 29.394, 'max_score': 7.045, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/BmKXBVdEV0g/pics/BmKXBVdEV0g7045.jpg'}, {'end': 82.652, 'src': 'embed', 'start': 52.97, 'weight': 1, 'content': [{'end': 57.293, 'text': "If you guys don't, I would highly recommend you first learn JavaScript before attempting this tutorial,", 'start': 52.97, 'duration': 4.323}, {'end': 59.334, 'text': "because it's going to be very hard to keep up with it.", 'start': 57.293, 'duration': 2.041}, {'end': 62.336, 'text': "Second, I'm assuming that you guys also have Node.js installed.", 'start': 59.534, 'duration': 2.802}, {'end': 66.239, 'text': "If you don't, you can go over to nodejs.org and you can install Node.js.", 'start': 62.376, 'duration': 3.863}, {'end': 73.044, 'text': "Discord bots are server-sided applications, so we need to make sure we're using a server-sided environment to actually run the application.", 'start': 66.439, 'duration': 6.605}, {'end': 77.788, 'text': 'Okay, but assuming you guys have JavaScript knowledge as well as Node.js installed,', 'start': 73.664, 'duration': 4.124}, {'end': 82.652, 'text': "what we're going to do first is we're actually going to go ahead and let me open up my Windows terminal.", 'start': 77.788, 'duration': 4.864}], 'summary': 'Prior knowledge of javascript and node.js is essential for creating discord bots, as they require a server-sided environment to run.', 'duration': 29.682, 'max_score': 52.97, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/BmKXBVdEV0g/pics/BmKXBVdEV0g52970.jpg'}, {'end': 188.284, 'src': 'embed', 'start': 150.121, 'weight': 0, 'content': [{'end': 153.822, 'text': "So I'm going to go ahead and just type npm init-y.", 'start': 150.121, 'duration': 3.701}, {'end': 159.725, 'text': "This is going to create a patch.json file which is going to be very important because, let's say, if we want to deploy our bot,", 'start': 153.922, 'duration': 5.803}, {'end': 163.726, 'text': "we're going to make sure we have all of our dependencies listed inside this patch.json file.", 'start': 159.725, 'duration': 4.001}, {'end': 166.347, 'text': 'And we also want to make sure we have our scripts as well.', 'start': 164.286, 'duration': 2.061}, {'end': 169.87, 'text': 'The next thing we want to do is we want to install Discord.js.', 'start': 166.627, 'duration': 3.243}, {'end': 171.451, 'text': 'This is a third-party module.', 'start': 170.07, 'duration': 1.381}, {'end': 174.253, 'text': "It's not part of the Node.js core library, so we have to install it.", 'start': 171.491, 'duration': 2.762}, {'end': 180.138, 'text': "Okay, this library is what we're going to be using to interact with the Discord API to create our Discord bot.", 'start': 174.453, 'duration': 5.685}, {'end': 186.843, 'text': 'Now I will mention right off the bat that this library is very powerful and it can also be a little bit complicated,', 'start': 180.298, 'duration': 6.545}, {'end': 188.284, 'text': 'depending on your knowledge of programming.', 'start': 186.843, 'duration': 1.441}], 'summary': 'Setup npm project, install discord.js for creating discord bot.', 'duration': 38.163, 'max_score': 150.121, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/BmKXBVdEV0g/pics/BmKXBVdEV0g150121.jpg'}], 'start': 7.045, 'title': 'Creating discord bot with javascript', 'summary': 'Covers creating a simple discord bot using javascript and node.js, emphasizing the use of discord.js module, and mentioning the importance of json, while offering insight into the complexities of the library and the need for object-oriented familiarity.', 'chapters': [{'end': 203.459, 'start': 7.045, 'title': 'Creating discord bot with javascript', 'summary': 'Covers creating a simple discord bot using javascript, assuming prerequisite knowledge of javascript and node.js, emphasizing the use of discord.js module and mentioning the importance of json, while offering insight into the complexities of the library and the need for object-oriented familiarity.', 'duration': 196.414, 'highlights': ['The chapter covers creating a simple Discord bot using JavaScript Anson teaches how to create a Discord bot using JavaScript, focusing on the Discord.js module.', 'Assuming prerequisite knowledge of JavaScript and Node.js Anson assumes viewers have prior knowledge of JavaScript and have Node.js installed.', 'Emphasizing the use of Discord.js module Anson highlights the importance of using the Discord.js module to interact with the Discord API.', 'Mentioning the importance of JSON Anson mentions the significance of JSON by creating a package.json file for dependencies and scripts.', 'Offering insight into the complexities of the library and the need for object-oriented familiarity Anson acknowledges the complexity of the Discord.js library and recommends familiarizing with object-oriented concepts.']}], 'duration': 196.414, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/BmKXBVdEV0g/pics/BmKXBVdEV0g7045.jpg', 'highlights': ['The chapter covers creating a simple Discord bot using JavaScript and Discord.js module.', 'Anson assumes viewers have prior knowledge of JavaScript and Node.js.', 'Anson highlights the importance of using the Discord.js module to interact with the Discord API.', 'Anson mentions the significance of JSON by creating a package.json file for dependencies and scripts.', 'Anson acknowledges the complexity of the Discord.js library and recommends familiarizing with object-oriented concepts.']}, {'end': 595.103, 'segs': [{'end': 259.701, 'src': 'embed', 'start': 222.195, 'weight': 1, 'content': [{'end': 232.544, 'text': 'okay, and you can see right over here that we now have this object over here, this dependencies object, which has discord.js and the version.', 'start': 222.195, 'duration': 10.349}, {'end': 236.506, 'text': "Okay, we're going to also install one more dependency called the env.", 'start': 233.004, 'duration': 3.502}, {'end': 239.228, 'text': 'This is going to allow us to use environment variables.', 'start': 237.127, 'duration': 2.101}, {'end': 242.33, 'text': "We're going to be using environment variables to store our bot token.", 'start': 239.448, 'duration': 2.882}, {'end': 246.152, 'text': "So the first thing we're going to do is we're going to create a source folder.", 'start': 242.59, 'duration': 3.562}, {'end': 250.555, 'text': 'So typically what I like to do is I like to create a new folder and I like to call it source, src.', 'start': 246.533, 'duration': 4.022}, {'end': 254.237, 'text': "And inside the source folder, I'm going to create my bot.js file.", 'start': 250.715, 'duration': 3.522}, {'end': 258.22, 'text': 'This is going to be the main entry point to our bots.', 'start': 254.758, 'duration': 3.462}, {'end': 259.701, 'text': "Okay, this is where we're going to keep all of our code.", 'start': 258.26, 'duration': 1.441}], 'summary': 'Installing discord.js and env dependencies, creating source folder and bot.js for main code.', 'duration': 37.506, 'max_score': 222.195, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/BmKXBVdEV0g/pics/BmKXBVdEV0g222195.jpg'}, {'end': 423.685, 'src': 'embed', 'start': 397.696, 'weight': 5, 'content': [{'end': 402.097, 'text': 'So this is going to basically load up all of the environment variables that are inside our .env file.', 'start': 397.696, 'duration': 4.401}, {'end': 407.879, 'text': 'Now, one thing that I will mention is that if you actually have environment variables set on your operating system,', 'start': 402.557, 'duration': 5.322}, {'end': 409.799, 'text': 'these environment variables will not override them.', 'start': 407.879, 'duration': 1.92}, {'end': 418.202, 'text': "So let's say if on my operating system I have an environment variable called discord.js.bot.token, And I have it set to some kind of value.", 'start': 410.259, 'duration': 7.943}, {'end': 423.685, 'text': "This bot token, or I'm sorry, this environment variable will not be interpreted with this value.", 'start': 418.482, 'duration': 5.203}], 'summary': "Loading .env file won't override os environment variables.", 'duration': 25.989, 'max_score': 397.696, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/BmKXBVdEV0g/pics/BmKXBVdEV0g397696.jpg'}, {'end': 527.77, 'src': 'heatmap', 'start': 444.074, 'weight': 0, 'content': [{'end': 448.078, 'text': "So to reference the environment variable, we're going to reference the global process object.", 'start': 444.074, 'duration': 4.004}, {'end': 454.283, 'text': 'And this object has a property called dot env or env, E-N-V, which is an object.', 'start': 448.858, 'duration': 5.425}, {'end': 457.426, 'text': "And we're going to reference the environment variable.", 'start': 454.984, 'duration': 2.442}, {'end': 459.988, 'text': 'So discord.js bot token.', 'start': 458.306, 'duration': 1.682}, {'end': 465.346, 'text': "Now, I'm going to go ahead and run the bot now, or run the script.", 'start': 462.205, 'duration': 3.141}, {'end': 468.967, 'text': "So we're going to type node source bot.js.", 'start': 465.486, 'duration': 3.481}, {'end': 475.669, 'text': "Whoops, what's going on here? node.sourcebot.js.", 'start': 470.627, 'duration': 5.042}, {'end': 476.989, 'text': 'There we go.', 'start': 476.689, 'duration': 0.3}, {'end': 478.99, 'text': 'And you can see that the script worked successfully.', 'start': 477.009, 'duration': 1.981}, {'end': 483.111, 'text': 'And you can see that our token was logged to the console.', 'start': 479.49, 'duration': 3.621}, {'end': 486.572, 'text': "So that's just a pretty simple example of how this whole thing works.", 'start': 483.391, 'duration': 3.181}, {'end': 489.993, 'text': "Now, the next problem is that we actually don't have our bot on our server.", 'start': 487.132, 'duration': 2.861}, {'end': 492.374, 'text': 'Okay, so right now I have my test server.', 'start': 490.473, 'duration': 1.901}, {'end': 495.917, 'text': 'You can actually just create a server by doing add server and click on create a server.', 'start': 492.435, 'duration': 3.482}, {'end': 497.138, 'text': 'And you can just name it whatever you want.', 'start': 496.017, 'duration': 1.121}, {'end': 498.259, 'text': "It's very easy.", 'start': 497.678, 'duration': 0.581}, {'end': 503.122, 'text': 'And when you have your server, what we want to do is we want to add our bot to the server.', 'start': 498.839, 'duration': 4.283}, {'end': 506.625, 'text': "So what we're going to do is we're going to go over to OAuth 2.", 'start': 503.222, 'duration': 3.403}, {'end': 507.926, 'text': "Well, first let's get the client ID.", 'start': 506.625, 'duration': 1.301}, {'end': 511.448, 'text': "So we're going to click on general information and we're going to copy the client ID.", 'start': 507.986, 'duration': 3.462}, {'end': 514.953, 'text': "And then what I'm going to do is I'm going to visit this URL.", 'start': 512.71, 'duration': 2.243}, {'end': 522.263, 'text': "So I'll leave the URL either in the video or I don't know if it'll be in the description, but I'll put it in the video.", 'start': 516.054, 'duration': 6.209}, {'end': 527.77, 'text': 'Basically, you want to go to discord.com slash API slash OAuth2 slash authorize.', 'start': 522.683, 'duration': 5.087}], 'summary': 'Reference environment variable and add bot to server using oauth2', 'duration': 83.696, 'max_score': 444.074, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/BmKXBVdEV0g/pics/BmKXBVdEV0g444074.jpg'}, {'end': 585.141, 'src': 'embed', 'start': 560.406, 'weight': 4, 'content': [{'end': 566.911, 'text': "So now, because we're authorizing our application as a bot, now we're going to go ahead and select the server that we want to add the bot to.", 'start': 560.406, 'duration': 6.505}, {'end': 571.675, 'text': 'Now, you can only add bots to servers where you have the managed server permission.', 'start': 567.572, 'duration': 4.103}, {'end': 577.439, 'text': "So that doesn't necessarily mean that you have to be the owner because there are different permissions when it comes to the Discord server.", 'start': 571.975, 'duration': 5.464}, {'end': 580.7, 'text': "But if you're the owner, then you definitely have the managed server permission.", 'start': 577.719, 'duration': 2.981}, {'end': 585.141, 'text': "So what I'm going to do is I'm just going to select the server that I own, so Arizona server.", 'start': 581.5, 'duration': 3.641}], 'summary': 'To add a bot to a server, one must have managed server permission, which is typically held by the owner.', 'duration': 24.735, 'max_score': 560.406, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/BmKXBVdEV0g/pics/BmKXBVdEV0g560406.jpg'}], 'start': 203.459, 'title': 'Discord bot setup and management', 'summary': 'Details the process of setting up a discord bot using node.js, covering installation, creating source files, environment variable setup, and securing the bot token. it also includes adding the bot to a discord server, managing environment variables, loading from .env file, referencing in the code, and demonstrating bot addition to a server with scope and permissions.', 'chapters': [{'end': 378.924, 'start': 203.459, 'title': 'Setting up a discord bot with node.js', 'summary': 'Covers the detailed process of setting up a discord bot using node.js, including installing dependencies, creating source files, setting up environment variables, and obtaining and securing the bot token from the discord developer portal.', 'duration': 175.465, 'highlights': ['Installing discord.js and environment variable dependency The chapter instructs to install discord.js and another dependency for environment variables, emphasizing the need to use environment variables to store the bot token.', "Creating source folder and bot.js file It explains the creation of a source folder and a bot.js file as the main entry point for the bot's code.", 'Obtaining and securing bot token from Discord developer portal The process of obtaining the bot token from the Discord developer portal is detailed, along with the importance of keeping the token private and instructions on how to regenerate the token if compromised.']}, {'end': 595.103, 'start': 379.685, 'title': 'Adding bot to discord server & managing environment variables', 'summary': 'Covers adding a bot to a discord server and managing environment variables, including loading environment variables from a .env file and referencing them in the code, with a demonstration of adding a bot to a server and managing scopes and permissions.', 'duration': 215.418, 'highlights': ['The chapter covers adding a bot to a Discord server and managing environment variables, including loading environment variables from a .env file and referencing them in the code, with a demonstration of adding a bot to a server and managing scopes and permissions.', 'The process of loading environment variables from a .env file is explained, highlighting that environment variables set on the operating system will not be overridden.', 'Demonstration of referencing environment variables in the code using the global process object, with a specific example of referencing the discord.js bot token.', "Detailed demonstration of adding a bot to a Discord server, including obtaining the client ID, visiting the OAuth2 authorization URL, setting the scope to 'bot', and selecting the server to authorize the bot."]}], 'duration': 391.644, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/BmKXBVdEV0g/pics/BmKXBVdEV0g203459.jpg', 'highlights': ['Details the process of setting up a discord bot using node.js, covering installation, creating source files, environment variable setup, and securing the bot token.', 'Obtaining and securing bot token from Discord developer portal, emphasizing the need to use environment variables to store the bot token.', "Creating source folder and bot.js file as the main entry point for the bot's code.", 'The chapter covers adding a bot to a Discord server and managing environment variables, including loading environment variables from a .env file and referencing them in the code.', "Demonstration of adding a bot to a Discord server, including obtaining the client ID, visiting the OAuth2 authorization URL, setting the scope to 'bot', and selecting the server to authorize the bot.", 'The process of loading environment variables from a .env file is explained, highlighting that environment variables set on the operating system will not be overridden.', 'Demonstration of referencing environment variables in the code using the global process object, with a specific example of referencing the discord.js bot token.']}, {'end': 1373.588, 'segs': [{'end': 635.091, 'src': 'embed', 'start': 595.744, 'weight': 2, 'content': [{'end': 600.685, 'text': 'Now, if I go over to Discord, you can see that it says Discord JS tutorial bot has joined.', 'start': 595.744, 'duration': 4.941}, {'end': 603.305, 'text': 'OK, it says today at 6.27 AM.', 'start': 600.765, 'duration': 2.54}, {'end': 604.886, 'text': 'And our bot is over here.', 'start': 603.906, 'duration': 0.98}, {'end': 611.131, 'text': "now our bot is in the server, but it's not online, so let's actually get it online.", 'start': 605.646, 'duration': 5.485}, {'end': 613.533, 'text': 'so to do that, we need to actually use code.', 'start': 611.131, 'duration': 2.402}, {'end': 615.895, 'text': "so that's going to be the next part of this tutorial.", 'start': 613.533, 'duration': 2.362}, {'end': 617.436, 'text': 'so actually logging the bot in.', 'start': 615.895, 'duration': 1.541}, {'end': 622.741, 'text': 'so one thing that i will mention right off the bat is that if you guys need a reference to the discord.js library,', 'start': 617.436, 'duration': 5.305}, {'end': 626.924, 'text': 'you can actually go to discordjs.org and you can click on documentation.', 'start': 622.741, 'duration': 4.183}, {'end': 633.19, 'text': 'they also do have a guide as well that you can go through if you prefer a text-based guide or text-based tutorial.', 'start': 626.924, 'duration': 6.266}, {'end': 635.091, 'text': "It's actually very informative.", 'start': 633.87, 'duration': 1.221}], 'summary': 'Discord js bot joined server, but not online. next, code needed for login. reference at discordjs.org.', 'duration': 39.347, 'max_score': 595.744, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/BmKXBVdEV0g/pics/BmKXBVdEV0g595744.jpg'}, {'end': 841.755, 'src': 'heatmap', 'start': 772.644, 'weight': 5, 'content': [{'end': 776.346, 'text': 'And you never want to do this with any type of credential because credentials are very sensitive.', 'start': 772.644, 'duration': 3.702}, {'end': 778.248, 'text': 'So, you want to make sure you keep it private.', 'start': 776.467, 'duration': 1.781}, {'end': 779.869, 'text': 'You want to keep it inside an environment variable.', 'start': 778.268, 'duration': 1.601}, {'end': 782.471, 'text': "But we're going to reference the environment variable like we did earlier.", 'start': 780.069, 'duration': 2.402}, {'end': 786.453, 'text': 'So, discord.js.bots.token.', 'start': 782.871, 'duration': 3.582}, {'end': 787.574, 'text': 'Just like that.', 'start': 787.114, 'duration': 0.46}, {'end': 793.055, 'text': "okay, you want to make sure it matches and now let's actually run our bot.", 'start': 788.434, 'duration': 4.621}, {'end': 795.556, 'text': 'so you can see, right now it is currently offline,', 'start': 793.055, 'duration': 2.501}, {'end': 803.657, 'text': "but I'm gonna go ahead and just type node dot slash source bot.js and you can see our bot just went online, which is pretty cool.", 'start': 795.556, 'duration': 8.101}, {'end': 809.638, 'text': "okay, now I'm actually kind of tired of just typing node dot slash source bot.js.", 'start': 803.657, 'duration': 5.981}, {'end': 812.059, 'text': "so what I'm actually gonna do is I'm gonna set up two scripts.", 'start': 809.638, 'duration': 2.421}, {'end': 819.322, 'text': "I'm going to set up a start script and this start script is actually going to be very important if we want to deploy our bot to, let's say, Heroku,", 'start': 813.599, 'duration': 5.723}, {'end': 819.802, 'text': 'for example.', 'start': 819.322, 'duration': 0.48}, {'end': 826.426, 'text': 'The start script is basically just going to be an alias for node.slashsourcebot.js.', 'start': 820.803, 'duration': 5.623}, {'end': 831.368, 'text': 'Now, instead of typing that in all the time, I can just type npm run start.', 'start': 827.106, 'duration': 4.262}, {'end': 837.212, 'text': "And you can see it's just an alias for node.slash source bot.js.", 'start': 832.449, 'duration': 4.763}, {'end': 839.494, 'text': "Okay, and it's going to run the application.", 'start': 837.913, 'duration': 1.581}, {'end': 841.755, 'text': "I'm also going to set up a dev script.", 'start': 840.334, 'duration': 1.421}], 'summary': 'Secure credentials by using environment variables, run bot with start script, deploy bot with heroku.', 'duration': 69.111, 'max_score': 772.644, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/BmKXBVdEV0g/pics/BmKXBVdEV0g772644.jpg'}, {'end': 839.494, 'src': 'embed', 'start': 813.599, 'weight': 1, 'content': [{'end': 819.322, 'text': "I'm going to set up a start script and this start script is actually going to be very important if we want to deploy our bot to, let's say, Heroku,", 'start': 813.599, 'duration': 5.723}, {'end': 819.802, 'text': 'for example.', 'start': 819.322, 'duration': 0.48}, {'end': 826.426, 'text': 'The start script is basically just going to be an alias for node.slashsourcebot.js.', 'start': 820.803, 'duration': 5.623}, {'end': 831.368, 'text': 'Now, instead of typing that in all the time, I can just type npm run start.', 'start': 827.106, 'duration': 4.262}, {'end': 837.212, 'text': "And you can see it's just an alias for node.slash source bot.js.", 'start': 832.449, 'duration': 4.763}, {'end': 839.494, 'text': "Okay, and it's going to run the application.", 'start': 837.913, 'duration': 1.581}], 'summary': 'Setting up a start script as an alias for node.slashsourcebot.js to run the application efficiently.', 'duration': 25.895, 'max_score': 813.599, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/BmKXBVdEV0g/pics/BmKXBVdEV0g813599.jpg'}, {'end': 1343.638, 'src': 'embed', 'start': 1309.049, 'weight': 0, 'content': [{'end': 1309.829, 'text': "It's a message type.", 'start': 1309.049, 'duration': 0.78}, {'end': 1314.631, 'text': "And I'm going to go to the documentation once again because I want to encourage you guys to use documentation.", 'start': 1309.949, 'duration': 4.682}, {'end': 1321.492, 'text': "If I go over to events, so remember that's classes, click on client, click on events or scroll over down over here.", 'start': 1315.411, 'duration': 6.081}, {'end': 1325.273, 'text': "And if you go over here and if you click on message, that's the name of the event.", 'start': 1321.993, 'duration': 3.28}, {'end': 1330.914, 'text': 'And it says emitted whenever a message is created, which basically means whenever a message is sent to a channel.', 'start': 1325.773, 'duration': 5.141}, {'end': 1334.015, 'text': 'And it says over here, parameter type description.', 'start': 1331.275, 'duration': 2.74}, {'end': 1337.356, 'text': 'So the parameter over here, these are basically the parameters for the callback function.', 'start': 1334.095, 'duration': 3.261}, {'end': 1343.638, 'text': "Okay, so if you see, let's say, for example, for the message reaction add if you see more than one parameter,", 'start': 1338.016, 'duration': 5.622}], 'summary': 'Encouraging use of documentation for understanding message event parameters.', 'duration': 34.589, 'max_score': 1309.049, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/BmKXBVdEV0g/pics/BmKXBVdEV0g1309049.jpg'}], 'start': 595.744, 'title': 'Discord bot basics', 'summary': 'Covers setting up a discord bot online and basic usage of discord.js library. it emphasizes the process of importing, creating client, handling events, and the importance of object-oriented programming. key points include using code and referencing discord.js library, setting up scripts for deployment, and focusing on event handling and client properties.', 'chapters': [{'end': 652.823, 'start': 595.744, 'title': 'Discord bot tutorial: getting bot online', 'summary': 'Demonstrates the process of getting a discord bot online, emphasizing the importance of using code and referencing the discord.js library, which provides informative documentation and guides.', 'duration': 57.079, 'highlights': ['The chapter emphasizes the importance of using code to get the bot online, setting the stage for the next part of the tutorial.', 'It highlights the availability of the discord.js library for reference, emphasizing its informative documentation and guides.', "The chapter recommends visiting discordjs.org for additional resources, showcasing the developers' effort in documenting their entire library."]}, {'end': 1373.588, 'start': 652.823, 'title': 'Discord.js basics: importing, creating client, and handling events', 'summary': 'Provides a tutorial on importing classes from discord.js, creating an instance of the client class for bot interaction, using environment variables for sensitive information, setting up scripts for deployment, and handling events like ready and message, emphasizing the importance of object-oriented programming, with a focus on event handling and client properties.', 'duration': 720.765, 'highlights': ['Setting up scripts for deployment and development using npm run commands The author explains the importance of setting up start and dev scripts for deployment and development, providing an alias for node.slashsourcebot.js and using nodemon for automatic restart upon file changes.', "Handling events like ready and message, emphasizing the importance of object-oriented programming and client properties The tutorial covers the registration and handling of events, such as the 'ready' event triggered upon successful bot login and the 'message' event triggered when a message is sent to a channel, highlighting the importance of object-oriented programming and the properties of the client class.", 'Using environment variables for sensitive information like bot token The importance of using environment variables to store sensitive information like bot tokens is emphasized to maintain security, preventing the exposure of credentials and ensuring data privacy.']}], 'duration': 777.844, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/BmKXBVdEV0g/pics/BmKXBVdEV0g595744.jpg', 'highlights': ["The tutorial covers the registration and handling of events, such as the 'ready' event and the 'message' event, emphasizing the importance of object-oriented programming and client properties.", 'Setting up scripts for deployment and development using npm run commands, providing an alias for node.slashsourcebot.js and using nodemon for automatic restart upon file changes.', 'The chapter emphasizes the importance of using code to get the bot online, setting the stage for the next part of the tutorial.', "The chapter recommends visiting discordjs.org for additional resources, showcasing the developers' effort in documenting their entire library.", 'The chapter highlights the availability of the discord.js library for reference, emphasizing its informative documentation and guides.', 'The importance of using environment variables to store sensitive information like bot tokens is emphasized to maintain security, preventing the exposure of credentials and ensuring data privacy.']}, {'end': 1842.883, 'segs': [{'end': 1399.92, 'src': 'embed', 'start': 1373.608, 'weight': 1, 'content': [{'end': 1380.09, 'text': "So let's say, for example, if the message has any files that were sent with it, we can get those files by referencing attachments.", 'start': 1373.608, 'duration': 6.482}, {'end': 1383.431, 'text': 'If I want to get the author that sent the message, I can reference message.author.', 'start': 1380.37, 'duration': 3.061}, {'end': 1389.374, 'text': 'Okay, if I want to get the channel that the message was sent in, I can do message.channel and etc.', 'start': 1384.691, 'duration': 4.683}, {'end': 1390.475, 'text': "So let's just do a basic thing.", 'start': 1389.474, 'duration': 1.001}, {'end': 1396.178, 'text': "So let's say if I want to get the actual message that the user sent, we can actually reference message.content.", 'start': 1390.495, 'duration': 5.683}, {'end': 1399.92, 'text': 'Okay, so if I go over here, this is the content of the message.', 'start': 1396.198, 'duration': 3.722}], 'summary': 'Retrieve message details like files, author, channel, and content using specific references.', 'duration': 26.312, 'max_score': 1373.608, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/BmKXBVdEV0g/pics/BmKXBVdEV0g1373608.jpg'}, {'end': 1446.262, 'src': 'embed', 'start': 1414.71, 'weight': 0, 'content': [{'end': 1415.871, 'text': 'and see what it says, hello.', 'start': 1414.71, 'duration': 1.161}, {'end': 1419.695, 'text': 'So we basically sent a message, okay? This event was omitted.', 'start': 1415.971, 'duration': 3.724}, {'end': 1423.519, 'text': 'And when this event was omitted, if we want to handle it, we need the callback function.', 'start': 1419.996, 'duration': 3.523}, {'end': 1426.843, 'text': 'The callback function takes one parameter, which is a message type.', 'start': 1423.679, 'duration': 3.164}, {'end': 1430.727, 'text': "And the message object itself has a bunch of properties and we're referencing content.", 'start': 1426.963, 'duration': 3.764}, {'end': 1437.153, 'text': "okay, now let's say if i want to get the user that sent the message, so let's, uh, log something more descriptive,", 'start': 1431.167, 'duration': 5.986}, {'end': 1439.676, 'text': "so let's do something like the user.", 'start': 1437.153, 'duration': 2.523}, {'end': 1443.259, 'text': "or let's do, uh, let's do this message.", 'start': 1439.676, 'duration': 3.583}, {'end': 1446.262, 'text': "so again i'm using a template strings and string interpolation.", 'start': 1443.259, 'duration': 3.003}], 'summary': 'The transcript covers handling omitted events and using callback functions for message content and user data.', 'duration': 31.552, 'max_score': 1414.71, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/BmKXBVdEV0g/pics/BmKXBVdEV0g1414710.jpg'}, {'end': 1519.331, 'src': 'embed', 'start': 1490.39, 'weight': 2, 'content': [{'end': 1491.711, 'text': "Let's create a more advanced..", 'start': 1490.39, 'duration': 1.321}, {'end': 1493.271, 'text': 'This is kind of like our own custom logger.', 'start': 1491.711, 'duration': 1.56}, {'end': 1496.332, 'text': "And then we'll just log the message.", 'start': 1495.212, 'duration': 1.12}, {'end': 1498.293, 'text': 'So message.content, just like that.', 'start': 1496.812, 'duration': 1.481}, {'end': 1500.673, 'text': "So let's do hello.", 'start': 1499.193, 'duration': 1.48}, {'end': 1502.594, 'text': 'And you can see..', 'start': 1500.693, 'duration': 1.901}, {'end': 1504.574, 'text': 'Oh, wait, our bot is not logged in yet.', 'start': 1502.594, 'duration': 1.98}, {'end': 1506.535, 'text': 'Just give it a couple of seconds.', 'start': 1505.135, 'duration': 1.4}, {'end': 1509.563, 'text': 'Okay, just say hi.', 'start': 1508.362, 'duration': 1.201}, {'end': 1512.786, 'text': 'All right, so you can see I have my discriminator and the message that I had sent.', 'start': 1509.803, 'duration': 2.983}, {'end': 1513.786, 'text': 'So let me just do one more.', 'start': 1512.826, 'duration': 0.96}, {'end': 1515.408, 'text': "Let's just say hello world.", 'start': 1513.806, 'duration': 1.602}, {'end': 1517.749, 'text': 'There we have hello world.', 'start': 1516.629, 'duration': 1.12}, {'end': 1519.331, 'text': "Okay, so that's pretty straightforward.", 'start': 1517.99, 'duration': 1.341}], 'summary': 'Creating a custom logger, logging messages, and verifying bot login.', 'duration': 28.941, 'max_score': 1490.39, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/BmKXBVdEV0g/pics/BmKXBVdEV0g1490390.jpg'}, {'end': 1856.27, 'src': 'embed', 'start': 1824.575, 'weight': 3, 'content': [{'end': 1826.275, 'text': 'this time the bot sends the message.', 'start': 1824.575, 'duration': 1.7}, {'end': 1833.999, 'text': "perfectly fine, but it doesn't send it over and over again because we are checking to see if the message was sent by a bot and if it is,", 'start': 1826.275, 'duration': 7.724}, {'end': 1834.799, 'text': 'we are returning.', 'start': 1833.999, 'duration': 0.8}, {'end': 1838.541, 'text': "so it's not going to execute anything after this, anything after this line over here.", 'start': 1834.799, 'duration': 3.742}, {'end': 1840.402, 'text': 'So hopefully that part makes sense.', 'start': 1839.361, 'duration': 1.041}, {'end': 1842.883, 'text': "So that's a very simple response from the bot.", 'start': 1840.742, 'duration': 2.141}, {'end': 1850.027, 'text': 'Alright. so the next thing that I want to do is I want to show you guys how to get started with setting up some simple commands for our Discord text channels.', 'start': 1843.003, 'duration': 7.024}, {'end': 1856.27, 'text': "So if you guys aren't familiar with what text commands are, basically with most chat applications, they have their own commands.", 'start': 1850.587, 'duration': 5.683}], 'summary': "Bot checks if message sent by bot, won't send repeatedly. setting up simple commands for discord text channels.", 'duration': 31.695, 'max_score': 1824.575, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/BmKXBVdEV0g/pics/BmKXBVdEV0g1824575.jpg'}], 'start': 1373.608, 'title': 'Javascript message handling and custom logger', 'summary': 'Covers message handling in javascript, including properties like attachments, author, and channel, and showcases callback functions. it also explains creating a custom logger and handling bot responses, utilizing string interpolation and conditional checks.', 'chapters': [{'end': 1430.727, 'start': 1373.608, 'title': 'Message handling in javascript', 'summary': 'Explains how to handle messages in javascript, referencing properties like attachments, author, channel, and content, and showcasing the use of callback functions to handle events.', 'duration': 57.119, 'highlights': ['The chapter explains how to handle messages in JavaScript, referencing properties like attachments, author, channel, and content, and showcasing the use of callback functions to handle events.', 'The message object has properties like attachments, author, channel, and content, which can be referenced to access specific message details.', 'The callback function for handling message events takes one parameter, which is a message type.']}, {'end': 1842.883, 'start': 1431.167, 'title': 'Custom logger and bot responses', 'summary': 'Demonstrates how to create a custom logger for message content and explains how to handle bot responses to prevent repetitive message sending, utilizing string interpolation and conditional checks.', 'duration': 411.716, 'highlights': ['Creating a custom logger using string interpolation and message content logging. Demonstrates the use of template strings and string interpolation to log descriptive user messages and create a custom logger.', "Handling bot responses by checking message content and sending conditional replies to users. Illustrates the use of conditional checks to respond to specific user messages, such as sending a reply when the user types 'hello' and ignoring bot messages.", 'Preventing repetitive message sending and handling bot messages to avoid infinite message loops. Explains the importance of checking the author of the message to prevent repetitive message sending and avoid infinite message loops caused by bot responses triggering the message event.']}], 'duration': 469.275, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/BmKXBVdEV0g/pics/BmKXBVdEV0g1373608.jpg', 'highlights': ['The callback function for handling message events takes one parameter, which is a message type.', 'The message object has properties like attachments, author, channel, and content, which can be referenced to access specific message details.', 'Creating a custom logger using string interpolation and message content logging.', 'Handling bot responses by checking message content and sending conditional replies to users.', 'Preventing repetitive message sending and handling bot messages to avoid infinite message loops.']}, {'end': 2671.251, 'segs': [{'end': 1910.682, 'src': 'embed', 'start': 1859.892, 'weight': 0, 'content': [{'end': 1865.476, 'text': 'If you actually look on Discord, if you type forward slash, there are actually some built-in commands that Discord provides for you.', 'start': 1859.892, 'duration': 5.584}, {'end': 1870.679, 'text': "But these commands aren't enough, because sometimes we might want certain commands to do other things,", 'start': 1865.676, 'duration': 5.003}, {'end': 1873.641, 'text': 'such as fetching data from an API or getting data from a database, etc.', 'start': 1870.679, 'duration': 2.962}, {'end': 1876.082, 'text': "So we're going to go ahead and create our own commands.", 'start': 1874.581, 'duration': 1.501}, {'end': 1880.465, 'text': 'So one thing that I will need to mention is that commands basically start with a prefix.', 'start': 1876.843, 'duration': 3.622}, {'end': 1883.326, 'text': "So in our case, we're going to use the dollar sign for our prefix.", 'start': 1880.665, 'duration': 2.661}, {'end': 1886.128, 'text': 'And then after prefix is going to be our command name.', 'start': 1883.607, 'duration': 2.521}, {'end': 1890.691, 'text': 'So for example, dollar sign and then kick, that would be the kick command.', 'start': 1886.228, 'duration': 4.463}, {'end': 1894.933, 'text': "And commands typically do not have spaces and you shouldn't have spaces with your commands.", 'start': 1891.331, 'duration': 3.602}, {'end': 1897.795, 'text': "It's going to make it a lot harder to really set it up anyways.", 'start': 1894.953, 'duration': 2.842}, {'end': 1902.698, 'text': 'but after the space, everything else after is implied to be a command argument.', 'start': 1897.795, 'duration': 4.903}, {'end': 1907.94, 'text': 'so, for example, if i want to set up a simple kick command, i want to kick someone from the server,', 'start': 1902.698, 'duration': 5.242}, {'end': 1910.682, 'text': 'i would do dollar sign kick and then i would pass in the user id.', 'start': 1907.94, 'duration': 2.742}], 'summary': 'Discord supports built-in commands, but additional custom commands are needed for specific functionalities such as fetching data from an api or a database. custom commands start with a prefix, in this case, a dollar sign, followed by the command name, and may include command arguments.', 'duration': 50.79, 'max_score': 1859.892, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/BmKXBVdEV0g/pics/BmKXBVdEV0g1859892.jpg'}, {'end': 2170.175, 'src': 'embed', 'start': 2140.979, 'weight': 3, 'content': [{'end': 2143.668, 'text': "So instead what I'm going to do is I'm going to do something called array destructuring.", 'start': 2140.979, 'duration': 2.689}, {'end': 2150.941, 'text': "Okay, And what I'm doing first is the first element in the array is going to be structured,", 'start': 2143.688, 'duration': 7.253}, {'end': 2154.264, 'text': 'is going to be destructured into this command name variable.', 'start': 2150.941, 'duration': 3.323}, {'end': 2162.169, 'text': 'And then every other element after that array is going to be stored inside this args variable, which is going to be an array.', 'start': 2154.804, 'duration': 7.365}, {'end': 2170.175, 'text': "So with this spreader operator, what it's basically doing, it's basically just unpacking all of those elements in the array into this args variable.", 'start': 2162.63, 'duration': 7.545}], 'summary': 'Using array destructuring to unpack elements into variables.', 'duration': 29.196, 'max_score': 2140.979, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/BmKXBVdEV0g/pics/BmKXBVdEV0g2140979.jpg'}, {'end': 2440.928, 'src': 'embed', 'start': 2414.547, 'weight': 4, 'content': [{'end': 2420.232, 'text': 'Okay, and the Guild member manager basically manages all of the members that belong to the Guild, and there are other properties and methods.', 'start': 2414.547, 'duration': 5.685}, {'end': 2429.099, 'text': 'So you can do things such as bang the user, you can fetch the user, you can prune the user or, yeah, you can prune the user, you can resolve the user,', 'start': 2420.792, 'duration': 8.307}, {'end': 2430.6, 'text': 'you can unban the user, etc.', 'start': 2429.099, 'duration': 1.501}, {'end': 2432.501, 'text': "Now notice how there's no kick method.", 'start': 2431.04, 'duration': 1.461}, {'end': 2435.904, 'text': 'So we actually need to get the member from the cache.', 'start': 2432.782, 'duration': 3.122}, {'end': 2440.928, 'text': "Okay, so we're going to go ahead and reference message.guild.members.", 'start': 2436.444, 'duration': 4.484}], 'summary': 'The guild member manager manages all members and associated methods like bang, fetch, prune, resolve, and unban, but it lacks a kick method. to address this, one should retrieve the member from the cache and reference message.guild.members.', 'duration': 26.381, 'max_score': 2414.547, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/BmKXBVdEV0g/pics/BmKXBVdEV0g2414547.jpg'}], 'start': 1843.003, 'title': 'Setting up discord text commands', 'summary': 'Demonstrates setting up custom commands for discord text channels by defining a prefix, explaining command structure, and emphasizing the need for data fetching and database interaction. it also covers handling command prefix and arguments, array destructuring, regular expressions, and utilizing guild member manager for user kicks.', 'chapters': [{'end': 1929.012, 'start': 1843.003, 'title': 'Setting up discord text commands', 'summary': 'Demonstrates how to set up custom commands for discord text channels, starting with defining a prefix for commands and explaining the structure of a command, while emphasizing the need for custom commands for fetching data and interacting with databases.', 'duration': 86.009, 'highlights': ['Commands enhance chat usage and can be customized for specific tasks such as fetching data from APIs or databases. Custom commands allow for enhancing chat usage and performing tasks like fetching data from APIs or databases, beyond the built-in commands provided by Discord.', 'The prefix for commands is defined as the dollar sign, followed by the command name and optional command arguments. The prefix for commands is established as the dollar sign, followed by the command name, and any subsequent text is considered as command arguments, making it essential for executing specific tasks.', "Demonstration of setting up a kick command with the syntax 'dollar sign kick