| 1 | \page editing-channels-and-messages Editing Channels and Messages |
| 2 | |
| 3 | Sometimes we need to update an object, such as a message (whether it's plain text or an embed) or a channel. At first, it might seem confusing, but it's actually really simple! You need an object with all the properties being identical to the existing one. Say you're editing a message. You need to have an object with its ID the same as the one in Discord. Then you replace what you need, such as its content. |
| 4 | |
| 5 | \note This example uses callback functions and embeds. To see more information about them, visit \ref callback-functions and \ref embed-message. |
| 6 | |
| 7 | ## Editing messages |
| 8 | Here we send a message and edit it after. To do so, we first reply to the command `msg-send` with some text, "This is a message" in our case. As described above, on the next step the message object is taken and the text is replaced with whatever the user desires. |
| 9 | |
| 10 | \include{cpp} editing_messages1.cpp |
| 11 | |
| 12 | \note Your bot can't edit messages sent by others!\ref embed-message. |
| 13 | |
| 14 | Before editing the message: |
| 15 | |
| 16 | \image html stuff_edit1.png |
| 17 | |
| 18 | After editing the message: |
| 19 | |
| 20 | \image html stuff_edit2.png |
| 21 | |
| 22 | ## Editing channels |
| 23 | Now we'll want to edit an existing channel - its name in this case. This works similarly to how messages are edited. |
| 24 | |
| 25 | \include{cpp} editing_messages2.cpp |
| 26 | |
| 27 | Before editing the channel: |
| 28 | |
| 29 | \image html stuff_edit3.png |
| 30 | |
| 31 | After editing the channel: |
| 32 | |
| 33 | \image html stuff_edit4.png |
| 34 | |
| 35 | ## Editing embeds |
| 36 | Now let's send an embed and edit it. If a message has one `content` field, it can have a few `embed` fields, up to 10 to be precise. So we first get the embed we want and edit and change its description. |
| 37 | |
| 38 | \include{cpp} editing_messages3.cpp |
| 39 | |
| 40 | Before editing the embed: |
| 41 | |
| 42 | \image html stuff_edit5.png |
| 43 | |
| 44 | Finally, after editing the embed: |
| 45 | |
| 46 | \image html stuff_edit6.png |