# Discord Tweet Broadcaster ## Part 1 — Intro to Discord.js ### *2* Congratulations, you've got your bot up and running, and working for the ping/pong command. That's pretty much the foundation for all of Discord bots. Now you can listen to [music](https://www.youtube.com/watch?v=OHodbKTzpA8) for the rest. Let's look at what you've done. ![](https://i.imgur.com/lK2djxG.png) That `on` part creates a listener for — you guessed it — `'messageCreate'`, which is — you guessed it — the creation of a message. When the listener is fired (i.e. on the creation of a message) it executes some function that you specify (in this case, asking if the content of the message is 'ping' and replying 'pong' if so). The parameter (`msg`) of that function (the ping/pong function) is the object of the message that caused the listener to fire. We're calling the parameter `msg`, but it would still be the same message object if it had any other name. These objects are the core of Discord.js, and they often interlink. Take a look docs for the [Message Object](https://discord.js.org/#/docs/main/stable/class/Message). Among it's properties is [content](https://discord.js.org/#/docs/main/stable/class/Message?scrollTo=content) (hence `msg.content`) ![](https://i.imgur.com/gKNe7Ks.png) Which, if you click it in the docs, says it's returns a string of the content of the message. Another property of the Message Object is author (`msg.author`) which returns the [User Object](https://discord.js.org/#/docs/discord.js/main/class/User) of the user that made the message. Yet another property is channel (`msg.channel`) which is a the object a the [Channel Object](https://discord.js.org/#/docs/discord.js/main/class/TextChannel) for the channel the message was sent in. One of the methods for the channel object is send ![](https://i.imgur.com/i2gN8zx.png) It can take in a string. This is important. If you ever want your bot to send a message that *isn't a reply*, you need to specify a channel. You can then do `someChannel.send('My message')`. If you wanted to send a message in the same channel a command was sent in *without making it a reply* it would look like `msg.channel.send('My message')` Take a look through the docs and get a feel for how things connect with eachother. Click on random properties and methods and see what they do. The search in the docs isn't perfect, but overall the docs are great and you can always find what you're looking for ## Challenges **Challenge 1: Announcement Bot** Upon typing `!announce my-announcement` the bot should broadcast `my-announcement` in *a different channel* than the one the command was given in. `my-announcement` can be *any string of words*, not just the literal 'my-announcement'! **Challenge 2: Happy Bot** Upon typing `!sad` the bot should react to that message with a smiley face emoji. **Challenge 3: Love/Hate Letter Bot** If Ryan gives a heart emoji reaction to Amanda's message, the bot send a message @mentioning Amanda saying that @Ryan likes them. If a mad face emoji reaction is given, the bot should do a similar message saying that the user that gave the emoji reaction doesn't like the user that it was given to. ## Hints * You will need to add `GUILD_MESSAGE_REACTIONS` to your intents array * `client.on('messageCreate')` listens for new messages. If you want to have your bot listen for emoji reactions, you'll need to make another listener for that. Search the docs! * The Bot can't read reactions from messages made before it was turned on. For testing, just use your bot for Challenge 3 ## Resources * [Discord.js Docs](https://discord.js.org/#/docs/discord.js/main/general/welcome) * Google.com — search 'my-query discord.js' * Trial & Error — Read your error messages, they are there for a reason