title
How to Build a Discord Bot - Full JavaScript Chatbot Tutorial

description
Learn to code a Discord bot with JavaScript using Node.js. 🔗 Written Tutorial - https://www.devdungeon.com/content/javascript-discord-bot-tutorial 🔗 Unicode Emojis - https://unicode.org/emoji/charts/full-emoji-list.html 🔗 Official Documentation - https://discord.js.org Tutorial by Dev Dungeon. Check out their YouTube channel: https://www.youtube.com/channel/UCgkG68BiCngkoV7I2BLtAVg -- Learn to code for free and get a developer job: https://www.freecodecamp.org Read hundreds of articles on programming: https://medium.freecodecamp.org

detail
{'title': 'How to Build a Discord Bot - Full JavaScript Chatbot Tutorial', 'heatmap': [{'end': 364.481, 'start': 341.604, 'weight': 0.717}, {'end': 492.683, 'start': 455.47, 'weight': 1}], 'summary': 'This tutorial provides a comprehensive guide on creating and setting up discord bots in javascript with node.js, covering registration, custom commands, emoji reactions, bot status, server interaction, message handling, and creating custom bot commands, including practical examples and considerations for handling incoming messages and creating custom commands.', 'chapters': [{'end': 241.787, 'segs': [{'end': 37.366, 'src': 'embed', 'start': 14.65, 'weight': 0, 'content': [{'end': 22.275, 'text': "We're going to start at the very beginning with how to register with Discord and create your own server, all the way through creating custom commands,", 'start': 14.65, 'duration': 7.625}, {'end': 24.777, 'text': 'adding emoji, reactions to messages and more.', 'start': 22.275, 'duration': 2.502}, {'end': 31.081, 'text': 'Also check out some of the other tutorials for Discord that are available, including how to write Discord bots in Python.', 'start': 25.297, 'duration': 5.784}, {'end': 37.366, 'text': "If you aren't already familiar with Discord, it is a great text and voice chat platform that's free to use.", 'start': 31.982, 'duration': 5.384}], 'summary': 'Learn how to register with discord, create a server, add custom commands, emoji, reactions, and explore other tutorials including python bots.', 'duration': 22.716, 'max_score': 14.65, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/8o25pRbXdFw/pics/8o25pRbXdFw14650.jpg'}, {'end': 124.601, 'src': 'embed', 'start': 97.021, 'weight': 1, 'content': [{'end': 102.443, 'text': 'You should see a general channel, and on the member list to the right, you should see your user.', 'start': 97.021, 'duration': 5.422}, {'end': 108.871, 'text': 'Now that you have your very own server to mess around with, you will need to register an app with Discord.', 'start': 103.487, 'duration': 5.384}, {'end': 117.996, 'text': 'Go to the Discord Developer Portal at discordapp.com slash developers, and then click on Create an Application.', 'start': 109.551, 'duration': 8.445}, {'end': 120.558, 'text': 'Fill out the name of your application.', 'start': 118.777, 'duration': 1.781}, {'end': 124.601, 'text': "By default, it's named My Application, but you should give it a custom name.", 'start': 120.798, 'duration': 3.803}], 'summary': 'To create a discord app, register at discordapp.com/developers and fill out the application name.', 'duration': 27.58, 'max_score': 97.021, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/8o25pRbXdFw/pics/8o25pRbXdFw97021.jpg'}, {'end': 195.644, 'src': 'embed', 'start': 149.339, 'weight': 3, 'content': [{'end': 152.802, 'text': "so it's important to keep this a secret and don't share it with anybody.", 'start': 149.339, 'duration': 3.463}, {'end': 154.463, 'text': "you don't want to control your bot.", 'start': 152.802, 'duration': 1.661}, {'end': 160.108, 'text': "I'm showing mine for this tutorial only, but I will be deleting it afterwards so nobody can use it.", 'start': 155.164, 'duration': 4.944}, {'end': 165.569, 'text': 'later you will use this token in the source code, so save it.', 'start': 160.868, 'duration': 4.701}, {'end': 171.79, 'text': "now that you have a server, an app and a bot user, there's one more step we have to do with discord.", 'start': 165.569, 'duration': 6.221}, {'end': 176.831, 'text': "your bot can be invited to many servers, but right now it doesn't belong to any server.", 'start': 171.79, 'duration': 5.041}, {'end': 180.232, 'text': "so we'll need to invite the bot to your server.", 'start': 176.831, 'duration': 3.401}, {'end': 187.776, 'text': 'click on the oauth 2 section on the left side of the page and then scroll down slightly to the Scopes section.', 'start': 180.232, 'duration': 7.544}, {'end': 191.9, 'text': 'Check the bot scope and it will generate a URL.', 'start': 188.577, 'duration': 3.323}, {'end': 195.644, 'text': 'Copy that URL and paste it into your web browser.', 'start': 192.601, 'duration': 3.043}], 'summary': 'Setting up a bot for discord, including generating a token and inviting the bot to a server.', 'duration': 46.305, 'max_score': 149.339, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/8o25pRbXdFw/pics/8o25pRbXdFw149339.jpg'}], 'start': 0.229, 'title': 'Creating and setting up discord bots', 'summary': 'Provides a tutorial on creating discord bots in javascript with node.js, covering the process of registration, creating custom commands, adding emoji, and reactions to messages. additional tutorials for discord bots in python are included. the chapter also explains the process of setting up a discord bot, including registering an app, adding a bot, obtaining a token, and inviting the bot to a server, with an emphasis on the security of the bot token and the authorization process.', 'chapters': [{'end': 96.24, 'start': 0.229, 'title': 'Creating discord bot in javascript', 'summary': 'Provides a tutorial on creating a discord bot in javascript with node.js, covering the process from registration to creating custom commands and adding emoji, reactions to messages, and more, with additional tutorials for discord bots in python and an invitation to join the devdungeon discord server.', 'duration': 96.011, 'highlights': ['The tutorial covers creating a Discord bot in JavaScript with Node.js, starting from registration to adding custom commands and emoji.', 'Discord is a free text and voice chat platform with web, mobile, and desktop apps, offering features for gamers, and DevDungeon has its own Discord server for programming and security-related discussions.', 'Instructions are provided for registering, logging in, and creating a server in Discord, with tips on selecting the region for faster server responses.']}, {'end': 241.787, 'start': 97.021, 'title': 'Setting up a discord bot', 'summary': 'Explains the process of creating and setting up a discord bot, including registering an app, adding a bot, obtaining a token, and inviting the bot to a server, with emphasis on the security of the bot token and the authorization process.', 'duration': 144.766, 'highlights': ["To create a Discord bot, register an application in the Discord Developer Portal, add a bot, obtain its token, and keep it secure, as it essentially serves as the bot's username and password combined into one string.", "After obtaining the bot's token, it should be saved for use in the source code.", 'To invite the bot to a server, navigate to the oauth 2 section, check the bot scope, generate a URL, and use it to authorize the bot to join the server, where it will appear as an offline user.', 'The same URL used to authorize the bot can be shared with others to invite the bot to their servers, enabling interaction without allowing control over the bot.']}], 'duration': 241.558, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/8o25pRbXdFw/pics/8o25pRbXdFw229.jpg', 'highlights': ['The tutorial covers creating a Discord bot in JavaScript with Node.js, starting from registration to adding custom commands and emoji.', 'To create a Discord bot, register an application in the Discord Developer Portal, add a bot, obtain its token, and keep it secure.', 'Instructions are provided for registering, logging in, and creating a server in Discord, with tips on selecting the region for faster server responses.', "After obtaining the bot's token, it should be saved for use in the source code.", 'To invite the bot to a server, navigate to the oauth 2 section, check the bot scope, generate a URL, and use it to authorize the bot to join the server.']}, {'end': 519.484, 'segs': [{'end': 288.294, 'src': 'embed', 'start': 241.947, 'weight': 0, 'content': [{'end': 243.087, 'text': "You won't have to do this again.", 'start': 241.947, 'duration': 1.14}, {'end': 246.454, 'text': 'Now we can move on to writing the JavaScript code.', 'start': 244.113, 'duration': 2.341}, {'end': 251.517, 'text': 'Before we can do that, though, you need to make sure you have Node.js installed on your system.', 'start': 246.934, 'duration': 4.583}, {'end': 256.659, 'text': 'Open your system terminal and run node dash dash version.', 'start': 252.337, 'duration': 4.322}, {'end': 262.002, 'text': "If you get a response and it says 8.0 or higher, you're already good to go.", 'start': 257.399, 'duration': 4.603}, {'end': 271.111, 'text': 'But if you get a message like unrecognized program or some kind of error, you most likely need to go download and install Node.js.', 'start': 262.702, 'duration': 8.409}, {'end': 273.994, 'text': 'Get it from nodejs.org.', 'start': 271.552, 'duration': 2.442}, {'end': 281.643, 'text': 'After you have installed Node.js, you should be able to run node dash dash version in your terminal, and it should look something like this.', 'start': 274.575, 'duration': 7.068}, {'end': 288.294, 'text': "Next, I'm going to open Visual Studio Code, a free editor that works well with JavaScript.", 'start': 283.251, 'duration': 5.043}], 'summary': "Ensure node.js is installed; run 'node --version' to check. use visual studio code for javascript coding.", 'duration': 46.347, 'max_score': 241.947, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/8o25pRbXdFw/pics/8o25pRbXdFw241947.jpg'}, {'end': 369.225, 'src': 'heatmap', 'start': 341.604, 'weight': 2, 'content': [{'end': 345.207, 'text': "it should automatically put you in the directory that you opened and you're working in.", 'start': 341.604, 'duration': 3.603}, {'end': 350.691, 'text': 'In the terminal, run npm install discord.js.', 'start': 345.927, 'duration': 4.764}, {'end': 353.533, 'text': "You might see some warnings, and that's okay.", 'start': 351.451, 'duration': 2.082}, {'end': 355.254, 'text': "There shouldn't be any errors, though.", 'start': 353.833, 'duration': 1.421}, {'end': 360.558, 'text': 'At the time of this video, version 11 is the latest discord.js version.', 'start': 355.955, 'duration': 4.603}, {'end': 364.481, 'text': 'Future versions may change and break some of these examples.', 'start': 361.099, 'duration': 3.382}, {'end': 369.225, 'text': "so if that happens, check out the video description and the comments to see if there's any updates.", 'start': 364.481, 'duration': 4.744}], 'summary': "To work in the opened directory, run 'npm install discord.js' in the terminal. as of the video, version 11 is the latest discord.js version.", 'duration': 27.621, 'max_score': 341.604, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/8o25pRbXdFw/pics/8o25pRbXdFw341604.jpg'}, {'end': 406.913, 'src': 'embed', 'start': 382.2, 'weight': 3, 'content': [{'end': 389.044, 'text': "Let's write a very simple bot program just to make sure everything is installed properly and the bot user is working correctly.", 'start': 382.2, 'duration': 6.844}, {'end': 392.626, 'text': 'We will load the Discord module and then connect.', 'start': 389.984, 'duration': 2.642}, {'end': 393.766, 'text': "That's all it's going to do.", 'start': 392.966, 'duration': 0.8}, {'end': 400.43, 'text': 'When the bot successfully connects, we will have it print out a message to the console indicating that it did connect.', 'start': 394.587, 'duration': 5.843}, {'end': 406.913, 'text': 'In the file, write const discord equals require discord.js.', 'start': 401.35, 'duration': 5.563}], 'summary': 'Creating a simple bot program to connect to discord using discord.js.', 'duration': 24.713, 'max_score': 382.2, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/8o25pRbXdFw/pics/8o25pRbXdFw382200.jpg'}, {'end': 497.884, 'src': 'heatmap', 'start': 455.47, 'weight': 4, 'content': [{'end': 461.134, 'text': 'Click on your application, and then go to the bot section, and click to reveal the token.', 'start': 455.47, 'duration': 5.664}, {'end': 467.578, 'text': 'Pass the token as a string to the client.login function.', 'start': 463.475, 'duration': 4.103}, {'end': 475.459, 'text': "Let's test this now by executing the program in the terminal using node mybot.js.", 'start': 468.717, 'duration': 6.742}, {'end': 480.84, 'text': 'We should see a message printed out to our console to indicate success.', 'start': 476.959, 'duration': 3.881}, {'end': 484.701, 'text': 'And if we look at our server, the bot user should appear online.', 'start': 481.3, 'duration': 3.401}, {'end': 489.142, 'text': 'If you see the message in your console and the bot appears online, then congrats.', 'start': 485.501, 'duration': 3.641}, {'end': 492.683, 'text': 'Everything is installed correctly and your bot is configured properly.', 'start': 489.522, 'duration': 3.161}, {'end': 494.943, 'text': 'The hardest parts are all out of the way now.', 'start': 493.283, 'duration': 1.66}, {'end': 497.884, 'text': "Now we're going to focus on making your bot do fun things.", 'start': 495.483, 'duration': 2.401}], 'summary': 'Configure bot by revealing token and testing in terminal to ensure successful installation', 'duration': 48.758, 'max_score': 455.47, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/8o25pRbXdFw/pics/8o25pRbXdFw455470.jpg'}], 'start': 241.947, 'title': 'Setting up node.js and creating a simple discord bot', 'summary': "Covers setting up node.js and visual studio code for javascript development, including installing node.js, setting up visual studio code, and creating a simple discord bot in javascript, ensuring it appears online and testing the bot's functionality.", 'chapters': [{'end': 381.62, 'start': 241.947, 'title': 'Setting up node.js and visual studio code for javascript', 'summary': 'Covers setting up node.js and visual studio code for javascript development, including installing node.js, setting up visual studio code, creating a new directory for the project, and installing the discord.js module using npm.', 'duration': 139.673, 'highlights': ['Node.js is required for JavaScript development, with a minimum version of 8.0 needed, and can be installed from nodejs.org.', 'Visual Studio Code is recommended for JavaScript development, and the process of opening a new folder, creating a new file, and setting up the editor is explained.', "The installation of the discord.js module using npm is demonstrated, with the command 'npm install discord.js' used in the terminal of Visual Studio Code."]}, {'end': 519.484, 'start': 382.2, 'title': 'Creating a simple discord bot', 'summary': "Covers the process of creating a simple discord bot in javascript, including connecting to discord, triggering actions upon successful connection, and testing the bot's functionality, ensuring it appears online.", 'duration': 137.284, 'highlights': ["The chapter covers the process of creating a simple Discord bot in JavaScript, including connecting to Discord, triggering actions upon successful connection, and testing the bot's functionality, ensuring it appears online.", 'The program will print out a message to the console indicating a successful connection after executing the code.', "The steps to obtain the bot's secret token are outlined, directing the user to discordapp.com/developers and the bot section to reveal the token, which should then be passed as a string to the client.login function."]}], 'duration': 277.537, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/8o25pRbXdFw/pics/8o25pRbXdFw241947.jpg', 'highlights': ['Node.js is required for JavaScript development, with a minimum version of 8.0 needed, and can be installed from nodejs.org.', 'Visual Studio Code is recommended for JavaScript development, and the process of opening a new folder, creating a new file, and setting up the editor is explained.', "The installation of the discord.js module using npm is demonstrated, with the command 'npm install discord.js' used in the terminal of Visual Studio Code.", "The chapter covers the process of creating a simple Discord bot in JavaScript, including connecting to Discord, triggering actions upon successful connection, and testing the bot's functionality, ensuring it appears online.", 'The program will print out a message to the console indicating a successful connection after executing the code.', "The steps to obtain the bot's secret token are outlined, directing the user to discordapp.com/developers and the bot section to reveal the token, which should then be passed as a string to the client.login function."]}, {'end': 780.751, 'segs': [{'end': 605.49, 'src': 'embed', 'start': 546.685, 'weight': 0, 'content': [{'end': 550.786, 'text': "This will change the bot's status to say playing with JavaScript.", 'start': 546.685, 'duration': 4.101}, {'end': 552.787, 'text': "Let's run it and verify it works.", 'start': 551.247, 'duration': 1.54}, {'end': 559.47, 'text': "It looks like the bot's status did update.", 'start': 557.149, 'duration': 2.321}, {'end': 566.98, 'text': 'Good You can change the verb from playing to streaming, listening, or watching.', 'start': 559.89, 'duration': 7.09}, {'end': 572.602, 'text': "Let's change it to say watching YouTube instead of playing with JavaScript.", 'start': 567.72, 'duration': 4.882}, {'end': 580.426, 'text': "Let's remove the line we currently have and replace it with client.user.setActivity YouTube.", 'start': 573.283, 'duration': 7.143}, {'end': 584.889, 'text': "And as a second parameter, we're going to pass it type watching.", 'start': 581.167, 'duration': 3.722}, {'end': 589.791, 'text': "Let's run it again and make sure it works as expected.", 'start': 586.889, 'duration': 2.902}, {'end': 599.307, 'text': "Perfect Now let's extend the bot a little further to print out the list of all the servers that it's connected to.", 'start': 591.243, 'duration': 8.064}, {'end': 605.49, 'text': "Right now it's probably only connected to your one server, but it's possible that the bot belongs to many servers at once.", 'start': 599.827, 'duration': 5.663}], 'summary': "Modified bot's status to watching youtube, verified functionality, and expanded to list connected servers.", 'duration': 58.805, 'max_score': 546.685, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/8o25pRbXdFw/pics/8o25pRbXdFw546685.jpg'}, {'end': 728.479, 'src': 'embed', 'start': 699.99, 'weight': 2, 'content': [{'end': 707.016, 'text': "Why don't we have the bot send a message to the general channel that we just identified in the previous step whenever it connects.", 'start': 699.99, 'duration': 7.026}, {'end': 709.438, 'text': "We'll make it say, hello world.", 'start': 707.997, 'duration': 1.441}, {'end': 723.016, 'text': 'At the bottom of the onReady event block, write let GeneralChannel equals client.channels.get and pass it the ID of your channel as a string.', 'start': 710.569, 'duration': 12.447}, {'end': 728.479, 'text': 'On the next line, write GeneralChannel.send Hello World.', 'start': 724.016, 'duration': 4.463}], 'summary': "Bot sends 'hello world' message to general channel upon connection.", 'duration': 28.489, 'max_score': 699.99, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/8o25pRbXdFw/pics/8o25pRbXdFw699990.jpg'}, {'end': 780.751, 'src': 'embed', 'start': 755.175, 'weight': 3, 'content': [{'end': 760.16, 'text': 'const. attachment equals new discord dot attachment.', 'start': 755.175, 'duration': 4.985}, {'end': 765.183, 'text': 'We need to pass either a file name or a web URL to a file.', 'start': 761.121, 'duration': 4.062}, {'end': 768.025, 'text': 'This works the same for files and images.', 'start': 765.923, 'duration': 2.102}, {'end': 773.627, 'text': 'You can pass it a local file path to something on your hard disk or an internet address.', 'start': 768.565, 'duration': 5.062}, {'end': 777.409, 'text': "I'm going to provide a URL to the DevDungeon logo.", 'start': 774.428, 'duration': 2.981}, {'end': 780.751, 'text': 'You can use the same URL since it is publicly accessible.', 'start': 777.809, 'duration': 2.942}], 'summary': 'Discord attachment allows passing local file paths or web urls to share files and images.', 'duration': 25.576, 'max_score': 755.175, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/8o25pRbXdFw/pics/8o25pRbXdFw755175.jpg'}], 'start': 521.306, 'title': 'Bot status and server interaction', 'summary': "Explains updating a bot's status using javascript, changing the bot's activity, and interacting with discord servers to print server lists, available channels, and sending messages with attachments.", 'chapters': [{'end': 580.426, 'start': 521.306, 'title': 'Updating bot status with javascript', 'summary': "Explains how to update a bot's status using javascript, demonstrating how to modify the code to change the bot's activity and displaying the process of updating the status to watching youtube after connecting.", 'duration': 59.12, 'highlights': ["Demonstrates how to modify the code to update the bot's status using JavaScript, providing step-by-step instructions on changing the activity and verifying its functionality.", "Illustrates the process of updating the bot's status to watching YouTube after connecting, showcasing the ability to change the activity from playing to streaming, listening, or watching."]}, {'end': 780.751, 'start': 581.167, 'title': 'Discord bot server interaction', 'summary': "Discusses extending a discord bot to print out the list of servers it's connected to, then printing out the available channels for each server, and finally demonstrating how to send a message and attach a file or an image to a message.", 'duration': 199.584, 'highlights': ["Extending the bot to print out the list of servers it's connected to and the available channels for each server The chapter discusses adding code to print out the list of all the servers the bot is connected to and then print out all the available channels for each server.", "Sending a message to a specific channel when the bot connects The chapter explains how to make the bot send a 'Hello World' message to a specific channel when it connects, demonstrating the use of client.channels.get and GeneralChannel.send methods.", 'Demonstrating how to attach a file or an image to a message The chapter provides a demonstration of attaching a file or an image to a message by creating an attachment using new discord.attachment and passing a file name or a web URL.']}], 'duration': 259.445, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/8o25pRbXdFw/pics/8o25pRbXdFw521306.jpg', 'highlights': ["Illustrates the process of updating the bot's status to watching YouTube after connecting, showcasing the ability to change the activity from playing to streaming, listening, or watching.", "Extending the bot to print out the list of servers it's connected to and the available channels for each server The chapter discusses adding code to print out the list of all the servers the bot is connected to and then print out all the available channels for each server.", "Sending a message to a specific channel when the bot connects The chapter explains how to make the bot send a 'Hello World' message to a specific channel when it connects, demonstrating the use of client.channels.get and GeneralChannel.send methods.", 'Demonstrating how to attach a file or an image to a message The chapter provides a demonstration of attaching a file or an image to a message by creating an attachment using new discord.attachment and passing a file name or a web URL.', "Demonstrates how to modify the code to update the bot's status using JavaScript, providing step-by-step instructions on changing the activity and verifying its functionality."]}, {'end': 1130.861, 'segs': [{'end': 841.955, 'src': 'embed', 'start': 811.758, 'weight': 1, 'content': [{'end': 815.539, 'text': 'But what if we want to respond to an incoming message from someone else?', 'start': 811.758, 'duration': 3.781}, {'end': 824.582, 'text': "So far we've been triggering all of our code based off of the ready event, which is triggered after the bot connects and is ready to perform actions.", 'start': 816.119, 'duration': 8.463}, {'end': 830.424, 'text': "We're going to start using a different event now, one that is triggered every time a message is sent.", 'start': 825.222, 'duration': 5.202}, {'end': 832.686, 'text': 'that is the message event.', 'start': 831.124, 'duration': 1.562}, {'end': 837.711, 'text': 'Below the entire client ready event.', 'start': 833.547, 'duration': 4.164}, {'end': 841.955, 'text': "let's write client.on message.", 'start': 837.711, 'duration': 4.244}], 'summary': 'Respond to incoming messages using the message event.', 'duration': 30.197, 'max_score': 811.758, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/8o25pRbXdFw/pics/8o25pRbXdFw811758.jpg'}, {'end': 1064.299, 'src': 'embed', 'start': 891.801, 'weight': 0, 'content': [{'end': 897.086, 'text': 'If the message was sent by someone else other than the bot, the code will continue past these lines.', 'start': 891.801, 'duration': 5.285}, {'end': 900.749, 'text': "So after this if statement, let's have the bot reply.", 'start': 897.586, 'duration': 3.163}, {'end': 909.638, 'text': 'Write receivedMessage.channel.send messageReceived plus receivedMessage.content.', 'start': 901.27, 'duration': 8.368}, {'end': 916.424, 'text': 'This will have the bot respond in the same channel and echo back the message that it got as acknowledgement.', 'start': 910.418, 'duration': 6.006}, {'end': 920.036, 'text': 'This could be a public channel or a private message.', 'start': 917.455, 'duration': 2.581}, {'end': 922.098, 'text': "It'll work correctly for both.", 'start': 920.177, 'duration': 1.921}, {'end': 929.422, 'text': "Why don't we make the response a little more personalized? Let's have the bot tag the user who sent the message.", 'start': 923.278, 'duration': 6.144}, {'end': 935.645, 'text': 'To do this, we just need to reference the receivedMessage.Author and convert it to a string.', 'start': 929.942, 'duration': 5.703}, {'end': 942.769, 'text': 'Update the sentMessage to include receivedMessage.Author.ToString like this.', 'start': 936.325, 'duration': 6.444}, {'end': 950.877, 'text': "Let's run it again and make sure that it works.", 'start': 948.413, 'duration': 2.464}, {'end': 958.529, 'text': 'Good It looks like it tags the user who sent the message.', 'start': 955.724, 'duration': 2.805}, {'end': 966.222, 'text': "While we're at it, why don't we have the bot add an emoji reaction to the user's message?", 'start': 960.879, 'duration': 5.343}, {'end': 971.225, 'text': "Inside the onMessage event, let's have the bot add a reaction.", 'start': 967.063, 'duration': 4.162}, {'end': 976.668, 'text': 'Some servers have custom emojis that you can use, while others only have the default set.', 'start': 971.885, 'duration': 4.783}, {'end': 981.031, 'text': "Believe it or not, there's actually an international standard for emojis.", 'start': 977.208, 'duration': 3.823}, {'end': 984.773, 'text': 'You can check out all of the Unicode emojis at this link.', 'start': 981.551, 'duration': 3.222}, {'end': 986.654, 'text': "It's also in the video description.", 'start': 985.153, 'duration': 1.501}, {'end': 994.304, 'text': 'To add a reaction, we will write receivedMessage.react and pass it the emoji string.', 'start': 987.881, 'duration': 6.423}, {'end': 999.027, 'text': 'You can actually copy and paste the emoji itself into the source code.', 'start': 994.965, 'duration': 4.062}, {'end': 1004.81, 'text': 'A Unicode emoji is recognized as a character, just like a P or a Q.', 'start': 999.627, 'duration': 5.183}, {'end': 1012.634, 'text': "However, Discord does not support every single Unicode emoji, so you'll have to try it out and make sure the one that you want works.", 'start': 1004.81, 'duration': 7.824}, {'end': 1016.616, 'text': "For this example, we'll use the thumbs up, which is known to work.", 'start': 1013.174, 'duration': 3.442}, {'end': 1020.084, 'text': 'You can also use custom emojis on your server.', 'start': 1017.762, 'duration': 2.322}, {'end': 1026.047, 'text': 'To add custom emojis to a server, go to server settings, emoji, upload emoji.', 'start': 1020.404, 'duration': 5.643}, {'end': 1028.569, 'text': 'I will upload a sample one now to demonstrate.', 'start': 1026.708, 'duration': 1.861}, {'end': 1038.162, 'text': 'To use a custom emoji as a reaction, you will need to know the unique ID of the custom emoji.', 'start': 1032.338, 'duration': 5.824}, {'end': 1042.184, 'text': "We don't know what that ID is yet as I just uploaded it.", 'start': 1038.781, 'duration': 3.403}, {'end': 1048.167, 'text': "So why don't we just get every custom emoji from the server, print out its ID, and react with it.", 'start': 1042.605, 'duration': 5.562}, {'end': 1055.112, 'text': 'So add the code receivedMessage.guild.emojis.foreach.', 'start': 1048.528, 'duration': 6.584}, {'end': 1064.299, 'text': 'custom emoji, arrow, console.log, custom emoji name, custom emoji ID.', 'start': 1056.053, 'duration': 8.246}], 'summary': 'The transcript explains how to make a bot reply, tag users, and add emoji reactions in a discord server.', 'duration': 172.498, 'max_score': 891.801, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/8o25pRbXdFw/pics/8o25pRbXdFw891801.jpg'}], 'start': 781.371, 'title': 'Bot message handling and emojis in discord', 'summary': 'Covers practical examples and considerations for handling incoming messages, including echoing, tagging users, and adding emoji reactions. it also discusses using unicode and custom emojis in discord, including uploading, using, and reacting with emojis, as well as retrieving and reacting with custom emojis by their unique ids.', 'chapters': [{'end': 976.668, 'start': 781.371, 'title': 'Bot message handling', 'summary': "Covers how to handle incoming messages, including checking for the bot's own messages, echoing back the message, tagging the user, and adding an emoji reaction, demonstrating practical examples and considerations for message handling.", 'duration': 195.297, 'highlights': ["The chapter covers how to handle incoming messages, including checking for the bot's own messages, echoing back the message, tagging the user, and adding an emoji reaction. Practical examples and considerations for message handling.", 'The message event is triggered on every single message, including messages sent by the bot itself. Emphasizes the potential for an infinite loop and the need for a check to prevent the bot from responding to its own messages.', 'The code includes a check to see if the message author is the bot itself, and if so, it is ignored and the function exits. Demonstrates the implementation of a check to avoid the bot responding to its own messages.', "The bot replies in the same channel and echoes back the message that it received as an acknowledgment. Shows the bot's action upon receiving a message from someone else.", "The bot tags the user who sent the message and updates the sent message to include the user's name as acknowledgment. Illustrates personalizing the bot's response by tagging the user who sent the message."]}, {'end': 1130.861, 'start': 977.208, 'title': 'Using emojis in discord', 'summary': 'Discusses the international standard for emojis, using unicode and custom emojis in discord, including uploading, using, and reacting with emojis, as well as retrieving and reacting with custom emojis by their unique ids.', 'duration': 153.653, 'highlights': ['Discusses the international standard for emojis and provides a link to view all the Unicode emojis. The chapter mentions the existence of an international standard for emojis and provides a link to view all Unicode emojis.', 'Explains how to add a reaction using receivedMessage.react and passing the emoji string, as well as copying and pasting the emoji into the source code. It explains the process of adding a reaction using receivedMessage.react and passing the emoji string, as well as the option to copy and paste the emoji into the source code.', 'Discusses the limitations of Discord in supporting every single Unicode emoji and advises trying out emojis to ensure they work. The chapter highlights the limitation of Discord in supporting every single Unicode emoji and advises trying out emojis to ensure they work.', 'Describes the process of adding custom emojis to a server by going to server settings, emoji, and uploading the emoji. It describes the process of adding custom emojis to a server by going to server settings, emoji, and uploading the emoji.', 'Explains how to use custom emojis as reactions by retrieving their unique IDs, printing out the IDs, and reacting with the custom emojis. It explains the process of using custom emojis as reactions by retrieving their unique IDs, printing out the IDs, and reacting with the custom emojis.']}], 'duration': 349.49, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/8o25pRbXdFw/pics/8o25pRbXdFw781371.jpg', 'highlights': ["The chapter covers how to handle incoming messages, including checking for the bot's own messages, echoing back the message, tagging the user, and adding an emoji reaction.", 'The message event is triggered on every single message, including messages sent by the bot itself. Emphasizes the potential for an infinite loop and the need for a check to prevent the bot from responding to its own messages.', "The bot replies in the same channel and echoes back the message that it received as an acknowledgment. Shows the bot's action upon receiving a message from someone else.", "The bot tags the user who sent the message and updates the sent message to include the user's name as acknowledgment. Illustrates personalizing the bot's response by tagging the user who sent the message.", 'Discusses the international standard for emojis and provides a link to view all the Unicode emojis. The chapter mentions the existence of an international standard for emojis and provides a link to view all Unicode emojis.', 'Describes the process of adding custom emojis to a server by going to server settings, emoji, and uploading the emoji. It describes the process of adding custom emojis to a server by going to server settings, emoji, and uploading the emoji.', 'Explains how to use custom emojis as reactions by retrieving their unique IDs, printing out the IDs, and reacting with the custom emojis. It explains the process of using custom emojis as reactions by retrieving their unique IDs, printing out the IDs, and reacting with the custom emojis.', 'Explains how to add a reaction using receivedMessage.react and passing the emoji string, as well as copying and pasting the emoji into the source code. It explains the process of adding a reaction using receivedMessage.react and passing the emoji string, as well as the option to copy and paste the emoji into the source code.', 'Discusses the limitations of Discord in supporting every single Unicode emoji and advises trying out emojis to ensure they work. The chapter highlights the limitation of Discord in supporting every single Unicode emoji and advises trying out emojis to ensure they work.']}, {'end': 1640.923, 'segs': [{'end': 1195.693, 'src': 'embed', 'start': 1157.288, 'weight': 0, 'content': [{'end': 1159.409, 'text': 'There are many ways you can implement this.', 'start': 1157.288, 'duration': 2.121}, {'end': 1167.672, 'text': 'You could check the entire message to see if it contains the full command, or you could make the command take a variable number of parameters.', 'start': 1160.129, 'duration': 7.543}, {'end': 1175.655, 'text': "I'm going to walk through one way to create it that demonstrates making two commands, a help command and a multiply command.", 'start': 1168.432, 'duration': 7.223}, {'end': 1181.657, 'text': 'With these examples, you should have a good template for extending and creating more of your own custom commands.', 'start': 1176.375, 'duration': 5.282}, {'end': 1187.209, 'text': "First, let's start inside the onMessageEvent block.", 'start': 1182.947, 'duration': 4.262}, {'end': 1195.693, 'text': "Since the command will be a message, let's inspect the first character of the message and see if it equals the exclamation mark.", 'start': 1188.109, 'duration': 7.584}], 'summary': 'Demonstrating creation of custom commands for a bot using javascript', 'duration': 38.405, 'max_score': 1157.288, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/8o25pRbXdFw/pics/8o25pRbXdFw1157288.jpg'}, {'end': 1277.822, 'src': 'embed', 'start': 1215.981, 'weight': 6, 'content': [{'end': 1227.745, 'text': "so let's remove that character from the beginning of the string with let fullcommand equals receivedMessage.content.substr.", 'start': 1215.981, 'duration': 11.764}, {'end': 1229.386, 'text': 'This will remove the first character.', 'start': 1227.745, 'duration': 1.641}, {'end': 1236.604, 'text': "Next let's take the remaining string and split it into pieces based off of each space character.", 'start': 1230.498, 'duration': 6.106}, {'end': 1243.47, 'text': 'Let split command equals full command dot split and pass it a space.', 'start': 1237.705, 'duration': 5.765}, {'end': 1247.073, 'text': 'This will return an array containing each word.', 'start': 1244.291, 'duration': 2.782}, {'end': 1252.078, 'text': 'We want to treat the first word provided as the name of the command.', 'start': 1248.254, 'duration': 3.824}, {'end': 1254.513, 'text': "We'll call that the primary command.", 'start': 1252.691, 'duration': 1.822}, {'end': 1262.791, 'text': 'So write let primary command equals split command bracket 0.', 'start': 1255.634, 'duration': 7.157}, {'end': 1267.595, 'text': 'If there are any remaining words in the array, we want to store them as the arguments.', 'start': 1262.791, 'duration': 4.804}, {'end': 1273.719, 'text': 'Let arguments equal split command dot slice 1.', 'start': 1268.335, 'duration': 5.384}, {'end': 1277.822, 'text': 'This will exclude the first element and keep all of the rest of them if there are any.', 'start': 1273.719, 'duration': 4.103}], 'summary': 'Extract primary command and arguments from string.', 'duration': 61.841, 'max_score': 1215.981, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/8o25pRbXdFw/pics/8o25pRbXdFw1215981.jpg'}, {'end': 1396.128, 'src': 'embed', 'start': 1359.666, 'weight': 3, 'content': [{'end': 1363.369, 'text': "Let's also add an else statement to handle the case when arguments are passed.", 'start': 1359.666, 'duration': 3.703}, {'end': 1369.314, 'text': "In this case, we'll just respond saying, it looks like you need help with plus arguments.", 'start': 1363.889, 'duration': 5.425}, {'end': 1378.793, 'text': "Let's run this and try it out now.", 'start': 1377.011, 'duration': 1.782}, {'end': 1385.979, 'text': 'Try typing exclamation help and then exclamation help JavaScript and review the responses from the bot.', 'start': 1379.273, 'duration': 6.706}, {'end': 1396.128, 'text': "Let's add a second command so you get the idea of how to add more commands.", 'start': 1392.084, 'duration': 4.044}], 'summary': "Adding an 'else' statement to handle arguments, testing with 'exclamation help' and 'exclamation help javascript', and adding a second command.", 'duration': 36.462, 'max_score': 1359.666, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/8o25pRbXdFw/pics/8o25pRbXdFw1359666.jpg'}, {'end': 1598.785, 'src': 'embed', 'start': 1569.491, 'weight': 4, 'content': [{'end': 1573.974, 'text': 'One common question is how do I run the bot 24-7 all the time?', 'start': 1569.491, 'duration': 4.483}, {'end': 1578.437, 'text': "To keep a bot running all the time, you'll need to leave the program running all the time.", 'start': 1574.595, 'duration': 3.842}, {'end': 1582.82, 'text': 'You can do this by simply leaving your computer on all the time and never turning it off.', 'start': 1579.038, 'duration': 3.782}, {'end': 1585.222, 'text': 'This is not practical for most people, though.', 'start': 1583.36, 'duration': 1.862}, {'end': 1592.467, 'text': 'An alternative is to rent a cheap $5 a month server from a provider like Linode or DigitalOcean.', 'start': 1585.782, 'duration': 6.685}, {'end': 1598.785, 'text': 'They provide cheap Linux servers that run all the time in their data center, the cloud, as you call it.', 'start': 1593.581, 'duration': 5.204}], 'summary': 'To run a bot 24-7, consider renting a $5/month server from linode or digitalocean, offering constant running linux servers.', 'duration': 29.294, 'max_score': 1569.491, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/8o25pRbXdFw/pics/8o25pRbXdFw1569491.jpg'}], 'start': 1138.266, 'title': 'Creating custom bot commands in javascript', 'summary': 'Covers creating bot commands, including implementing commands triggered by special characters, demonstrating the creation of a help command, and a multiply command. it also explains the process of creating custom commands in javascript by inspecting and processing user messages to identify and execute specific commands, including extracting the primary command and arguments from the message. additionally, it demonstrates creating custom commands in a javascript bot, handling help, multiply commands, and provides suggestions for keeping the bot running 24-7, and additional resources for learning and support.', 'chapters': [{'end': 1175.655, 'start': 1138.266, 'title': 'Creating bot commands', 'summary': 'Covers creating bot commands, including implementing commands triggered by special characters and demonstrating the creation of two commands, a help command, and a multiply command.', 'duration': 37.389, 'highlights': ['Demonstrating the creation of two commands, a help command and a multiply command', 'Explaining the implementation of commands triggered by special characters', 'Discussing different ways to implement commands, such as checking the entire message for the full command or making the command take a variable number of parameters']}, {'end': 1303.139, 'start': 1176.375, 'title': 'Creating custom commands in javascript', 'summary': 'Explains the process of creating custom commands in javascript by inspecting and processing user messages to identify and execute specific commands, including extracting the primary command and arguments from the message.', 'duration': 126.764, 'highlights': ['Inspect the first character of the message and check if it equals the exclamation mark to identify the command trigger.', 'Create the processCommand function to handle the logic of processing the received message by removing the first character and splitting the remaining string into pieces based on space characters.', 'Extract the primary command and arguments from the message by treating the first word as the primary command and storing the remaining words as arguments.']}, {'end': 1640.923, 'start': 1303.139, 'title': 'Creating custom commands in javascript bot', 'summary': 'Demonstrates creating custom commands in a javascript bot, including handling help, multiply commands, and suggestions for further custom commands. it also provides suggestions for keeping the bot running 24-7 and additional resources for learning and support.', 'duration': 337.784, 'highlights': ['The chapter demonstrates creating custom commands in a JavaScript bot, including handling help, multiply commands, and suggestions for further custom commands.', 'To keep a bot running all the time, an alternative is to rent a cheap $5 a month server from a provider like Linode or DigitalOcean.', 'One common question is how do I run the bot 24-7 all the time? An alternative is to use something like a Raspberry Pi from your house and leave that running all the time.']}], 'duration': 502.657, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/8o25pRbXdFw/pics/8o25pRbXdFw1138266.jpg', 'highlights': ['Demonstrating the creation of two commands, a help command and a multiply command', 'Explaining the implementation of commands triggered by special characters', 'Discussing different ways to implement commands, such as checking the entire message for the full command or making the command take a variable number of parameters', 'The chapter demonstrates creating custom commands in a JavaScript bot, including handling help, multiply commands, and suggestions for further custom commands', 'To keep a bot running all the time, an alternative is to rent a cheap $5 a month server from a provider like Linode or DigitalOcean', 'Inspect the first character of the message and check if it equals the exclamation mark to identify the command trigger', 'Create the processCommand function to handle the logic of processing the received message by removing the first character and splitting the remaining string into pieces based on space characters', 'Extract the primary command and arguments from the message by treating the first word as the primary command and storing the remaining words as arguments', 'One common question is how do I run the bot 24-7 all the time? An alternative is to use something like a Raspberry Pi from your house and leave that running all the time']}], 'highlights': ['The tutorial covers creating a Discord bot in JavaScript with Node.js, starting from registration to adding custom commands and emoji.', 'Instructions are provided for registering, logging in, and creating a server in Discord, with tips on selecting the region for faster server responses.', 'To create a Discord bot, register an application in the Discord Developer Portal, add a bot, obtain its token, and keep it secure.', "After obtaining the bot's token, it should be saved for use in the source code.", 'To invite the bot to a server, navigate to the oauth 2 section, check the bot scope, generate a URL, and use it to authorize the bot to join the server.', 'Node.js is required for JavaScript development, with a minimum version of 8.0 needed, and can be installed from nodejs.org.', 'Visual Studio Code is recommended for JavaScript development, and the process of opening a new folder, creating a new file, and setting up the editor is explained.', "The installation of the discord.js module using npm is demonstrated, with the command 'npm install discord.js' used in the terminal of Visual Studio Code.", "The chapter covers the process of creating a simple Discord bot in JavaScript, including connecting to Discord, triggering actions upon successful connection, and testing the bot's functionality, ensuring it appears online.", "Illustrates the process of updating the bot's status to watching YouTube after connecting, showcasing the ability to change the activity from playing to streaming, listening, or watching.", "Extending the bot to print out the list of servers it's connected to and the available channels for each server The chapter discusses adding code to print out the list of all the servers the bot is connected to and then print out all the available channels for each server.", "Sending a message to a specific channel when the bot connects The chapter explains how to make the bot send a 'Hello World' message to a specific channel when it connects, demonstrating the use of client.channels.get and GeneralChannel.send methods.", "The chapter covers how to handle incoming messages, including checking for the bot's own messages, echoing back the message, tagging the user, and adding an emoji reaction.", 'The message event is triggered on every single message, including messages sent by the bot itself. Emphasizes the potential for an infinite loop and the need for a check to prevent the bot from responding to its own messages.', "The bot replies in the same channel and echoes back the message that it received as an acknowledgment. Shows the bot's action upon receiving a message from someone else.", "The bot tags the user who sent the message and updates the sent message to include the user's name as acknowledgment. Illustrates personalizing the bot's response by tagging the user who sent the message.", 'Discusses the limitations of Discord in supporting every single Unicode emoji and advises trying out emojis to ensure they work.', 'Demonstrating the creation of two commands, a help command and a multiply command', 'Explaining the implementation of commands triggered by special characters', 'The chapter demonstrates creating custom commands in a JavaScript bot, including handling help, multiply commands, and suggestions for further custom commands', 'To keep a bot running all the time, an alternative is to rent a cheap $5 a month server from a provider like Linode or DigitalOcean', 'Inspect the first character of the message and check if it equals the exclamation mark to identify the command trigger', 'Create the processCommand function to handle the logic of processing the received message by removing the first character and splitting the remaining string into pieces based on space characters', 'Extract the primary command and arguments from the message by treating the first word as the primary command and storing the remaining words as arguments', 'One common question is how do I run the bot 24-7 all the time? An alternative is to use something like a Raspberry Pi from your house and leave that running all the time']}