Let's convert our Discord bot to respond with embedded messages.
Embedded messages in Discord are a great way to make your bot's responses look a lot more visually appealing!
We'll create a new command called /bookclub
that will take in a book title, an author, and the number of hours until the submission deadline from the user. Then, it will reply
with an object that Discord will automatically convert into an embedded message.
Man 1: [0:00] To create an embedded message, let's create an object with the name of embed message.
[0:09] In here, we're going to add a few things. First thing will be our title with book. We're going to add in an author. That's going to be an object with the name of our author. We're going to add in a description of running a book club on the book, and our variable book.
[0:39] The last thing we'll add in is fields. Fields is going to be an array of a couple of objects. These objects needs a minimum of two things, a name and a value. The name for this one will be amount of people wanted, and the value will be our variable, num of people. Then we're going to add in another object for our hours.
[1:14] Name submissions, close in, hours. The value will be time runs out in our variable hours and hours. Perfect. Now, to send that embedded message, we need to reply to our interaction. Inside the parentheses, we need this to be an object with the key of embeds. The value for that will be our object, embed message.
[1:57] We'll come up here, remove our first message, save, open up our terminal, start our bot. Then we'll head over to discord and run our command. Testing, three people in three hours. Hit enter. There we go. A much nicer message than what we were seeing before.
[2:24] You can see we've got the title, we've got our author. Then we've got our description, running a book club on the book testing. The amount of people wanted were three and submissions close in three. Time runs out in three hours.
[2:41] The last thing I want to add is we could have multiple book clubs running on the same book. To differentiate between the two of those, we'll add in the date to our book, and that'll be added into the title.
[2:58] We'll create a new variable called book club. That equal to a string of book plus book club plus and then we'll do new date for today's date. We'll set that to date string. Come down here to our title, replace that with book club. Save.
[3:28] Our bot is refreshed. Come back over here, run our command again. You can see it's been updated with our new title.