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 ' for kicking a user from the server. Illustration of setting up a kick command using the syntax 'dollar sign kick ' to remove a user from the server, emphasizing the importance of understanding the command structure for effective implementation."]}, {'end': 2671.251, 'start': 1929.612, 'title': 'Handling command prefix and arguments', 'summary': 'Explains how to handle command prefix, extract command name and arguments from a message, and utilize array destructuring and regular expressions to manage commands. it also demonstrates how to access and utilize guild member manager to kick users based on provided id.', 'duration': 741.639, 'highlights': ['The chapter explains how to handle command prefix, extract command name and arguments from a message, and utilize array destructuring and regular expressions to manage commands. It provides insights on extracting the command name and arguments from a message, utilizing array destructuring for managing command name and arguments, and using regular expressions for pattern matching in the string.', 'It also demonstrates how to access and utilize guild member manager to kick users based on provided ID. It explains how to access guild member manager, utilize the cache collection to retrieve the guild member object, and implement a check for the presence of user-provided ID before executing the kick command.']}], 'duration': 828.248, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/BmKXBVdEV0g/pics/BmKXBVdEV0g1843003.jpg', 'highlights': ['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 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.', "Illustration of setting up a kick command using the syntax 'dollar sign kick ' to remove a user from the server, emphasizing the importance of understanding the command structure for effective implementation.", 'It provides insights on extracting the command name and arguments from a message, utilizing array destructuring for managing command name and arguments, and using regular expressions for pattern matching in the string.', 'It explains how to access guild member manager, utilize the cache collection to retrieve the guild member object, and implement a check for the presence of user-provided ID before executing the kick command.']}, {'end': 3233.143, 'segs': [{'end': 2734.186, 'src': 'embed', 'start': 2671.752, 'weight': 0, 'content': [{'end': 2678.436, 'text': 'Because if this member is not found in the cache, then that means the member is likely not actually in the guild itself.', 'start': 2671.752, 'duration': 6.684}, {'end': 2682.018, 'text': "Okay? So we're going to check to see if member is truthy.", 'start': 2678.996, 'duration': 3.022}, {'end': 2682.879, 'text': 'So if member.', 'start': 2682.319, 'duration': 0.56}, {'end': 2687.521, 'text': "So if that's the case, then we're going to go ahead and kick the user.", 'start': 2683.359, 'duration': 4.162}, {'end': 2690.663, 'text': 'so i can actually just do member dot kick.', 'start': 2687.521, 'duration': 3.142}, {'end': 2694.825, 'text': "okay, and i can provide a reason if i want to, but i'm just, i'm not going to do that for now.", 'start': 2690.663, 'duration': 4.162}, {'end': 2701.548, 'text': "and if the member is not found, then we'll just say message and we'll send this message to the channel and not reply to the user.", 'start': 2694.825, 'duration': 6.723}, {'end': 2708.511, 'text': "so we'll just say uh, that member was not found.", 'start': 2701.548, 'duration': 6.963}, {'end': 2712.23, 'text': 'okay, so watch this.', 'start': 2708.511, 'duration': 3.719}, {'end': 2715.812, 'text': "let's first do kick one, two, three.", 'start': 2712.23, 'duration': 3.582}, {'end': 2716.653, 'text': 'that member was not found.', 'start': 2715.812, 'duration': 0.841}, {'end': 2718.274, 'text': 'okay, now watch this.', 'start': 2716.653, 'duration': 1.621}, {'end': 2720.456, 'text': 'if i try to kick this bot,', 'start': 2718.274, 'duration': 2.182}, {'end': 2726.1, 'text': "you're gonna see that an error is gonna happen and it's saying missing permissions because our bot does not have permissions.", 'start': 2720.456, 'duration': 5.644}, {'end': 2728.762, 'text': 'so we need to go ahead and give our bot permissions.', 'start': 2726.1, 'duration': 2.662}, {'end': 2734.186, 'text': 'so typically what you should do is you should create a separate role for your bot.', 'start': 2728.762, 'duration': 5.424}], 'summary': 'Code checks for member, kicks if found, handles error messages.', 'duration': 62.434, 'max_score': 2671.752, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/BmKXBVdEV0g/pics/BmKXBVdEV0g2671752.jpg'}, {'end': 2956.86, 'src': 'embed', 'start': 2929.153, 'weight': 4, 'content': [{'end': 2931.714, 'text': "they'll actually return a promise okay.", 'start': 2929.153, 'duration': 2.561}, {'end': 2936.955, 'text': 'So we should technically handle the promise and we should also handle our errors in case it happens, because you never know what could happen.', 'start': 2932.134, 'duration': 4.821}, {'end': 2942.096, 'text': 'So when we resolve the promise, this will actually return the actual guild member that was kicked.', 'start': 2937.235, 'duration': 4.861}, {'end': 2948.178, 'text': 'So if I go to here, it will say kicks this member from the guild and returns promise guild member.', 'start': 2942.136, 'duration': 6.042}, {'end': 2949.738, 'text': 'So let me go ahead and do this.', 'start': 2948.498, 'duration': 1.24}, {'end': 2953.019, 'text': "So let's handle the promise by calling .then.", 'start': 2951.299, 'duration': 1.72}, {'end': 2956.86, 'text': 'This is going to give us the member that was kicked.', 'start': 2953.039, 'duration': 3.821}], 'summary': 'Handling promises and errors is important to ensure proper function; resolution returns the kicked guild member.', 'duration': 27.707, 'max_score': 2929.153, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/BmKXBVdEV0g/pics/BmKXBVdEV0g2929153.jpg'}, {'end': 3017.747, 'src': 'embed', 'start': 2989.638, 'weight': 5, 'content': [{'end': 2993.018, 'text': "We're just going to say message.channel send.", 'start': 2989.638, 'duration': 3.38}, {'end': 2996.319, 'text': 'I do not have permissions.', 'start': 2994.358, 'duration': 1.961}, {'end': 3003.301, 'text': 'Now keep in mind that the bot permissions are completely different than actual user permissions.', 'start': 2998.279, 'duration': 5.022}, {'end': 3008.883, 'text': "So you should always make sure you're checking to see who's executing certain commands.", 'start': 3004.122, 'duration': 4.761}, {'end': 3013.385, 'text': 'So in our case, this kick command is technically a moderation command.', 'start': 3009.444, 'duration': 3.941}, {'end': 3017.747, 'text': "So you want to make sure that you're checking to see if moderators are using this command.", 'start': 3013.785, 'duration': 3.962}], 'summary': 'Bot permissions differ from user permissions. moderators should execute kick command.', 'duration': 28.109, 'max_score': 2989.638, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/BmKXBVdEV0g/pics/BmKXBVdEV0g2989638.jpg'}], 'start': 2671.752, 'title': 'Discord bot member management', 'summary': 'Covers the process of kicking a member from the guild, including handling cases when the member is found or not found in the cache, as well as the importance of bot permissions, roles hierarchy, promise handling, and user permissions in discord bot commands, with examples of kick and ban commands.', 'chapters': [{'end': 2718.274, 'start': 2671.752, 'title': 'Discord bot member kicking process', 'summary': 'Demonstrates the process of checking for a member in the cache and kicking them from the guild, with a focus on handling cases where the member is found or not found in the cache.', 'duration': 46.522, 'highlights': ['The process involves checking if a member is found in the cache, and if not found, sending a corresponding message to the channel.', 'If the member is found, the bot proceeds to kick the user from the guild.', 'In case the member is not found, a message is sent to the channel indicating the absence of the member.']}, {'end': 3233.143, 'start': 2718.274, 'title': 'Discord bot permissions and commands', 'summary': 'Explains the importance of giving bot permissions, roles hierarchy, handling promises, and checking user permissions in discord bot commands. it covers examples of kick and ban commands, showing the need for proper permissions and error handling.', 'duration': 514.869, 'highlights': ['The importance of role hierarchy for bot permissions Explains the need to create a separate role for the bot, ensuring it has permissions above other users, and the impact of role hierarchy on bot actions.', 'Handling promises and errors in bot commands Emphasizes the need to handle promises returned by methods like .kick and to handle errors, ensuring proper execution and error messaging.', 'Checking user permissions for moderation commands Demonstrates the importance of checking user permissions for commands like kick and ban, ensuring that only authorized users can execute these commands.']}], 'duration': 561.391, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/BmKXBVdEV0g/pics/BmKXBVdEV0g2671752.jpg', 'highlights': ['The process involves checking if a member is found in the cache, and if not found, sending a corresponding message to the channel.', 'If the member is found, the bot proceeds to kick the user from the guild.', 'In case the member is not found, a message is sent to the channel indicating the absence of the member.', 'The importance of role hierarchy for bot permissions Explains the need to create a separate role for the bot, ensuring it has permissions above other users, and the impact of role hierarchy on bot actions.', 'Handling promises and errors in bot commands Emphasizes the need to handle promises returned by methods like .kick and to handle errors, ensuring proper execution and error messaging.', 'Checking user permissions for moderation commands Demonstrates the importance of checking user permissions for commands like kick and ban, ensuring that only authorized users can execute these commands.']}, {'end': 4077.33, 'segs': [{'end': 3273.67, 'src': 'embed', 'start': 3248.293, 'weight': 0, 'content': [{'end': 3255.32, 'text': "So we're going to do message.guild, and we're actually going to reference members, and we're going to call the ban method.", 'start': 3248.293, 'duration': 7.027}, {'end': 3258.744, 'text': "And the ban method takes in what's called a user resolvable.", 'start': 3255.861, 'duration': 2.883}, {'end': 3265.807, 'text': 'So user-resolvable can either be the actual user object, it can be the member object,', 'start': 3259.344, 'duration': 6.463}, {'end': 3273.67, 'text': "it can be the ID of the person that you're trying to kick or ban, or, I'm sorry, it can be the ID of the person that you're trying to ban.", 'start': 3265.807, 'duration': 7.863}], 'summary': 'Using message.guild to reference members and call the ban method with user-resolvable options.', 'duration': 25.377, 'max_score': 3248.293, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/BmKXBVdEV0g/pics/BmKXBVdEV0g3248293.jpg'}, {'end': 3340.666, 'src': 'embed', 'start': 3311.449, 'weight': 1, 'content': [{'end': 3313.713, 'text': "So I'm just going to go ahead and just catch the error.", 'start': 3311.449, 'duration': 2.264}, {'end': 3316.757, 'text': "I'm not going to resolve the promise with a .then.", 'start': 3314.314, 'duration': 2.443}, {'end': 3321.024, 'text': "I'll just log the error for now, just to show you guys what the errors look like.", 'start': 3317.238, 'duration': 3.786}, {'end': 3329.636, 'text': "Okay, so let's go ahead and let's try to, let's try to do ban 1, 2, 3, and let's see what happens.", 'start': 3322.83, 'duration': 6.806}, {'end': 3331.918, 'text': 'So you can see that it actually says unknown user.', 'start': 3329.656, 'duration': 2.262}, {'end': 3336.142, 'text': 'Okay, so unknown user basically means that the user is not found.', 'start': 3332.639, 'duration': 3.503}, {'end': 3340.666, 'text': 'So let me actually get the ID of a different bot that I have.', 'start': 3336.562, 'duration': 4.104}], 'summary': "Demonstrating catching and logging errors, showing 'unknown user' message and finding the id of a different bot.", 'duration': 29.217, 'max_score': 3311.449, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/BmKXBVdEV0g/pics/BmKXBVdEV0g3311449.jpg'}, {'end': 3400.903, 'src': 'embed', 'start': 3370.887, 'weight': 2, 'content': [{'end': 3376.69, 'text': 'if i actually want to see all the users that are banned, i can go to server settings and you can see that i have, uh, cinderace,', 'start': 3370.887, 'duration': 5.803}, {'end': 3377.53, 'text': 'which is my other bot.', 'start': 3376.69, 'duration': 0.84}, {'end': 3379.131, 'text': "that's the user that i ban.", 'start': 3377.53, 'duration': 1.601}, {'end': 3383.073, 'text': "so if you actually pass in an invalid user, then it actually won't work.", 'start': 3379.131, 'duration': 3.942}, {'end': 3387.395, 'text': "so the user actually needs to exist, but the user doesn't have to be in the same guild.", 'start': 3383.073, 'duration': 4.322}, {'end': 3390.277, 'text': "Okay, so let's actually handle our errors.", 'start': 3388.075, 'duration': 2.202}, {'end': 3395.02, 'text': "Like I said, we always want to handle our errors to provide any messages back to the user in case something doesn't work.", 'start': 3390.317, 'duration': 4.703}, {'end': 3400.903, 'text': "But this time, you know what I'm going to do? Instead of using .then and .catch, I want to switch it up a little bit.", 'start': 3395.66, 'duration': 5.243}], 'summary': 'The user can view banned users in server settings and handle errors without using .then and .catch.', 'duration': 30.016, 'max_score': 3370.887, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/BmKXBVdEV0g/pics/BmKXBVdEV0g3370887.jpg'}, {'end': 3429.787, 'src': 'embed', 'start': 3403.425, 'weight': 3, 'content': [{'end': 3412.152, 'text': 'So if you guys are not familiar with async-await, i highly recommend you learn and familiarize yourself with that, because with discord js,', 'start': 3403.425, 'duration': 8.727}, {'end': 3415.715, 'text': "a lot of these methods that you're going to call are going to return promises,", 'start': 3412.152, 'duration': 3.563}, {'end': 3419.838, 'text': "and there are going to be some times where you're going to actually need the data that is returned.", 'start': 3415.715, 'duration': 4.123}, {'end': 3421.299, 'text': 'okay, and you might want to reuse it for later on.', 'start': 3419.838, 'duration': 1.461}, {'end': 3429.787, 'text': "so what we're going to do is we're going to add the async keyword all the way in front of our callback function And then, right over here,", 'start': 3421.299, 'duration': 8.488}], 'summary': 'Learn async-await for managing promises in discord js.', 'duration': 26.362, 'max_score': 3403.425, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/BmKXBVdEV0g/pics/BmKXBVdEV0g3403425.jpg'}, {'end': 3504.946, 'src': 'embed', 'start': 3478.242, 'weight': 4, 'content': [{'end': 3481.846, 'text': "const user okay and we're going to await the promise.", 'start': 3478.242, 'duration': 3.604}, {'end': 3486.25, 'text': 'So this is going to wait until this promise has been fulfilled.', 'start': 3483.227, 'duration': 3.023}, {'end': 3488.952, 'text': "And it's going to return the user object.", 'start': 3487.351, 'duration': 1.601}, {'end': 3492.415, 'text': "Now, if I console log the user, it's going to give us the actual user data.", 'start': 3489.032, 'duration': 3.383}, {'end': 3494.677, 'text': 'And if I console log the error, it will tell us the error.', 'start': 3492.655, 'duration': 2.022}, {'end': 3496.599, 'text': "So let's try this again.", 'start': 3495.638, 'duration': 0.961}, {'end': 3500.041, 'text': "So let's go ahead and do ban123.", 'start': 3497.219, 'duration': 2.822}, {'end': 3502.804, 'text': "Okay, and let's type that.", 'start': 3501.323, 'duration': 1.481}, {'end': 3504.946, 'text': "And it's going to say unknown user.", 'start': 3502.864, 'duration': 2.082}], 'summary': 'Await promise returns user object, logs user data or error.', 'duration': 26.704, 'max_score': 3478.242, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/BmKXBVdEV0g/pics/BmKXBVdEV0g3478242.jpg'}, {'end': 3680.274, 'src': 'embed', 'start': 3656.44, 'weight': 5, 'content': [{'end': 3664.205, 'text': "So what we want to do is whenever we react to a certain emoji, when we react to a message with a certain emoji, it's going to give us a specific role.", 'start': 3656.44, 'duration': 7.765}, {'end': 3671.509, 'text': "I'm sure you guys have seen something like this before, where, if you go join a Discord server and then you click on, let's say, the roles channel,", 'start': 3664.785, 'duration': 6.724}, {'end': 3676.792, 'text': 'there are a bunch of messages and then it tells you which emoji will give you which role.', 'start': 3671.509, 'duration': 5.283}, {'end': 3680.274, 'text': 'so I have a couple of rules set up on my server already,', 'start': 3676.792, 'duration': 3.482}], 'summary': 'Implementing automatic role assignment based on emoji reactions in discord server.', 'duration': 23.834, 'max_score': 3656.44, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/BmKXBVdEV0g/pics/BmKXBVdEV0g3656440.jpg'}], 'start': 3233.523, 'title': 'Discord bot ban method and error handling in discord.js', 'summary': 'Covers the process of banning users in a discord bot, explaining user resolvables and handling errors with examples. it also discusses handling errors and utilizing async-await in discord.js, showcasing different techniques and providing examples.', 'chapters': [{'end': 3390.277, 'start': 3233.523, 'title': 'Discord bot ban method', 'summary': 'Covers the process of banning users using the ban method in a discord bot, explaining user resolvables and handling errors, with examples of unknown user and missing permissions.', 'duration': 156.754, 'highlights': ['The ban method in a Discord bot allows banning users using user resolvables such as user object, member object, or user ID, with a demonstration of directly banning a user using the ID.', "Demonstrating error handling by catching and logging errors, with examples of 'unknown user' and 'missing permissions' when attempting to ban users.", 'Explaining the requirement for bot permissions to enable banning members and the ability to view banned users in server settings.']}, {'end': 4077.33, 'start': 3390.317, 'title': 'Handling errors and using async-await in discord.js', 'summary': 'Discusses handling errors and utilizing async-await in discord.js, showcasing different techniques and providing examples of ban functionality and role reaction system setup.', 'duration': 687.013, 'highlights': ['The chapter emphasizes the importance of handling errors and introduces the usage of async-await instead of .then and .catch in Discord.js. The speaker recommends learning async-await due to Discord.js methods returning promises and the need for returned data, illustrating the addition of the async keyword and usage of try-catch.', "The speaker demonstrates the ban functionality and error handling using async-await, showcasing the retrieval of user data and error handling in case of unknown users. The speaker showcases using async-await to await the ban method's promise, enabling the retrieval of user data and error messages when banning unknown users.", 'The chapter illustrates the role reaction system setup, emphasizing the procedure to assign roles based on specific emoji reactions. The speaker explains the process of setting up a role reaction system where specific roles are assigned based on emoji reactions to a message, utilizing the Discord.js event messageReactionAdd and switch case to assign roles.']}], 'duration': 843.807, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/BmKXBVdEV0g/pics/BmKXBVdEV0g3233523.jpg', 'highlights': ['The ban method in a Discord bot allows banning users using user resolvables such as user object, member object, or user ID, with a demonstration of directly banning a user using the ID.', "Demonstrating error handling by catching and logging errors, with examples of 'unknown user' and 'missing permissions' when attempting to ban users.", 'Explaining the requirement for bot permissions to enable banning members and the ability to view banned users in server settings.', 'The chapter emphasizes the importance of handling errors and introduces the usage of async-await instead of .then and .catch in Discord.js.', 'The speaker demonstrates the ban functionality and error handling using async-await, showcasing the retrieval of user data and error handling in case of unknown users.', 'The chapter illustrates the role reaction system setup, emphasizing the procedure to assign roles based on specific emoji reactions.']}, {'end': 4651.232, 'segs': [{'end': 4170.823, 'src': 'embed', 'start': 4144.325, 'weight': 0, 'content': [{'end': 4151.649, 'text': 'okay?. Now the message reaction at event is only emitted for cached messages only.', 'start': 4144.325, 'duration': 7.324}, {'end': 4155.752, 'text': "So if the message is in memory, if it's saved in the collection, It's going to emit this event.", 'start': 4151.649, 'duration': 4.103}, {'end': 4158.595, 'text': "if it's not, it will not emit this event by default.", 'start': 4155.752, 'duration': 2.843}, {'end': 4163.218, 'text': 'So in order to work around this, we need to actually opt into something called partials.', 'start': 4158.595, 'duration': 4.623}, {'end': 4170.823, 'text': 'So partials are a discord.js concept that allow you to handle uncached data, So data that is not stored in the cache,', 'start': 4163.218, 'duration': 7.605}], 'summary': 'Message reaction event is emitted for cached messages only, opt into partials for uncached data handling.', 'duration': 26.498, 'max_score': 4144.325, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/BmKXBVdEV0g/pics/BmKXBVdEV0g4144325.jpg'}, {'end': 4207.656, 'src': 'embed', 'start': 4183.788, 'weight': 1, 'content': [{'end': 4192.353, 'text': "we're going to pass in an object inside the parentheses and we're going to specify partials and we're going to enable the user or not user.", 'start': 4183.788, 'duration': 8.565}, {'end': 4197.879, 'text': "we're going to enable the message partial And then the reaction partial because we're using message reaction add.", 'start': 4192.353, 'duration': 5.526}, {'end': 4199.402, 'text': 'So we need both of these.', 'start': 4198.5, 'duration': 0.902}, {'end': 4202.527, 'text': 'So now this should work without any doubt.', 'start': 4199.742, 'duration': 2.785}, {'end': 4204.591, 'text': 'So if I go back to the console.', 'start': 4203.148, 'duration': 1.443}, {'end': 4207.656, 'text': "And I'm going to react to the different emoji this time.", 'start': 4205.833, 'duration': 1.823}], 'summary': 'Passing an object with specified partials to enable user or not user, and message and reaction partials for message reaction add.', 'duration': 23.868, 'max_score': 4183.788, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/BmKXBVdEV0g/pics/BmKXBVdEV0g4183787.jpg'}, {'end': 4362.166, 'src': 'embed', 'start': 4332.618, 'weight': 2, 'content': [{'end': 4336.259, 'text': 'Okay, or any moderated role that might be underneath the Discord bots role.', 'start': 4332.618, 'duration': 3.641}, {'end': 4339.322, 'text': "Okay, so I'm going to show you guys how to use webhooks now.", 'start': 4336.619, 'duration': 2.703}, {'end': 4343.367, 'text': 'So if you guys are not familiar, Discord actually has webhook integration.', 'start': 4339.743, 'duration': 3.624}, {'end': 4346.69, 'text': 'So you can actually use, for example, webhooks with GitHub.', 'start': 4343.947, 'duration': 2.743}, {'end': 4354.839, 'text': 'So whenever someone triggers some kind of event on your GitHub repository, such as a star a fork, a pull request,', 'start': 4347.151, 'duration': 7.688}, {'end': 4357.602, 'text': 'it will send that message to a specific channel.', 'start': 4354.839, 'duration': 2.763}, {'end': 4362.166, 'text': "okay, so we're going to go ahead and first set up a web hook.", 'start': 4358.323, 'duration': 3.843}], 'summary': 'Discord has webhook integration with github for event notifications.', 'duration': 29.548, 'max_score': 4332.618, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/BmKXBVdEV0g/pics/BmKXBVdEV0g4332618.jpg'}, {'end': 4458.15, 'src': 'embed', 'start': 4424.027, 'weight': 3, 'content': [{'end': 4427.109, 'text': 'So let me go ahead and open up this.', 'start': 4424.027, 'duration': 3.082}, {'end': 4433.832, 'text': "And we're going to call this webhook ID, webhook token.", 'start': 4427.129, 'duration': 6.703}, {'end': 4436.113, 'text': "So first, let's get the ID.", 'start': 4434.932, 'duration': 1.181}, {'end': 4438.494, 'text': 'So there we go.', 'start': 4437.153, 'duration': 1.341}, {'end': 4439.894, 'text': "Let's get the token.", 'start': 4439.214, 'duration': 0.68}, {'end': 4441.975, 'text': 'There we go.', 'start': 4441.515, 'duration': 0.46}, {'end': 4442.735, 'text': 'Just like..', 'start': 4441.995, 'duration': 0.74}, {'end': 4446.327, 'text': 'like that.', 'start': 4444.907, 'duration': 1.42}, {'end': 4452.589, 'text': "okay, so now the next thing we're going to do is we want to instantiate the webhook client class.", 'start': 4446.327, 'duration': 6.262}, {'end': 4458.15, 'text': 'so discord js comes with the webhook client class that makes it very easy to use webhooks.', 'start': 4452.589, 'duration': 5.561}], 'summary': 'Setting up webhook id and token for webhook client class in discord js.', 'duration': 34.123, 'max_score': 4424.027, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/BmKXBVdEV0g/pics/BmKXBVdEV0g4424027.jpg'}], 'start': 4077.33, 'title': 'Discord bot message issues and webhook integration', 'summary': 'Covers fixing discord.js message reaction issue for uncached messages by enabling message and reaction partials, and explains discord bot webhook integration including setting up reaction roles, using webhooks for github integration, and sending messages using webhook client class.', 'chapters': [{'end': 4225.944, 'start': 4077.33, 'title': 'Fixing discord.js message reaction issue', 'summary': 'Highlights the issue of message reaction event not working for uncached messages in discord.js, explains the concept of partials and demonstrates how to enable message and reaction partials to resolve the issue, leading to successful message reactions for different emojis.', 'duration': 148.614, 'highlights': ['The message reaction add event is only emitted for cached messages, and in order to work with uncached data, partials need to be enabled, resulting in the successful handling of message reactions for different emojis.', 'Enabling message and reaction partials by adding one line of code inside the constructor (new client) allows the system to handle uncached data and successfully emit the message reaction add event, resolving the issue of message reactions not working for uncached messages.', 'Demonstrating successful message reactions for different emojis after enabling message and reaction partials, with examples of receiving different role assignments based on the emoji reactions, showcasing the resolution of the initial issue.']}, {'end': 4651.232, 'start': 4225.944, 'title': 'Discord bot webhook integration', 'summary': 'Explains the importance of opting into partials to handle cached messages in discord bot, demonstrates setting up reaction roles and using webhooks for integration with github, illustrating the process of setting up webhooks, extracting webhook information, and using the webhook client class to send messages.', 'duration': 425.288, 'highlights': ['The chapter explains the importance of opting into partials to handle cached messages in Discord bot Opting into partials is necessary to handle cached messages in Discord bot, ensuring messages are retrievable even after the bot restarts.', 'Demonstrates setting up reaction roles and using webhooks for integration with GitHub The tutorial demonstrates the process of setting up reaction roles and using webhooks for integration with GitHub, showcasing the practical application of these features.', 'Illustrating the process of setting up webhooks, extracting webhook information, and using the webhook client class to send messages The tutorial illustrates the detailed process of setting up webhooks, extracting webhook information, and utilizing the webhook client class to send messages, providing a comprehensive guide for implementing webhook integration.']}], 'duration': 573.902, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/BmKXBVdEV0g/pics/BmKXBVdEV0g4077330.jpg', 'highlights': ['Enabling message and reaction partials allows successful handling of uncached data and emitting the message reaction add event.', 'Demonstrating successful message reactions for different emojis after enabling message and reaction partials.', 'Demonstrates setting up reaction roles and using webhooks for integration with GitHub.', 'Illustrating the process of setting up webhooks, extracting webhook information, and using the webhook client class to send messages.']}], 'highlights': ['The tutorial emphasizes the importance of using the Discord.js module to interact with the Discord API.', '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.', "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.", '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 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.', 'The process involves checking if a member is found in the cache, and if not found, sending a corresponding message to the channel.', 'The importance of role hierarchy for bot permissions Explains the need to create a separate role for the bot, ensuring it has permissions above other users, and the impact of role hierarchy on bot actions.', 'The ban method in a Discord bot allows banning users using user resolvables such as user object, member object, or user ID, with a demonstration of directly banning a user using the ID.', 'Enabling message and reaction partials allows successful handling of uncached data and emitting the message reaction add event.', 'Demonstrates setting up reaction roles and using webhooks for integration with GitHub.']}