# Messages

## Features

* Sending messages remotely (from another channel)
* Editing messages that were 'sent' by someone else
* Deleting messages from the bot
* Fetching the raw message content
* Commands limited to users with a set role

## Usage

### Interactive modes

All message commands are interactive.\
This means that if parts of the command are not given, you will be prompted for them. An example of the `send` command and this being used is below:

![Interactive example](https://1355931420-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MDrSfgrxH3dw9lmECOD%2Fsync%2Fe04a175dcb6725fec43a3195164e867a13d61db4.png?generation=1601333477266508\&alt=media)

### Plain content messages

#### Sending messages

To send a message you must specify the channel and content to send.\
The content may be either just the exact message after the channel or enclosed in a code block with triple backticks ( \`\`\` ). If it is the code block will be removed before sending. If you would like to send a code block just put six backticks instead of three.

{% hint style="info" %}
The `<channel>` can be either the channel id or the channel mention.
{% endhint %}

`~send <channel> <content>`

Example:

![Sending a message](https://1355931420-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MDrSfgrxH3dw9lmECOD%2Fsync%2F1cbf775fd6220552d309f34934613f9c881e37bf.png?generation=1601333477595416\&alt=media)

![You can also do this](https://1355931420-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MDrSfgrxH3dw9lmECOD%2Fsync%2F26c15a1f29e6c3319f2d19fb434b273fdddf2fba.png?generation=1601333477797235\&alt=media)

![And the result](https://1355931420-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MDrSfgrxH3dw9lmECOD%2F-MIIRKMY0ZWvS0C5Tkii%2F-MIIjhPweYiHGe_KZmdS%2Fsend_2.png?alt=media\&token=a3229d61-1651-4cfe-905d-6d7f2a326034)

#### Editing Messages

To edit messages you need to provide the channel, message id and the new content\
The bot cannot edit messages that were not sent from the bot.

`~edit <channel> <message id> <new content>`

![Editing the message](https://1355931420-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MDrSfgrxH3dw9lmECOD%2F-MILhPNC6fFRrJItVjJU%2F-MILi0Ump_yAYaKAJoNW%2Fedit_1.png?alt=media\&token=be2b9187-58a4-4f73-a61b-8804c828bf44)

![The edited message](https://1355931420-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MDrSfgrxH3dw9lmECOD%2Fsync%2Fa8d04fd90de5dec96dd964e96a287120fd2e95e3.png?generation=1601333478218969\&alt=media)

### Rich Embed Messages

If you are struggling with the formatting, please join the support server and ask.

#### Sending rich embeds

When sending rich embeds there are two options.

**Sending basic embeds**

This will send an embed with only the title and description set. The command is `~send-embed <channel>` the bot will then prompt you for the title and then the description.

**Sending full embeds**

This is sending a fully customizable embed. The command will take the JSON version of an embed and turn it into an embed. The format for the JSON can be found on the [discord dev website](https://discord.com/developers/docs/resources/channel#embed-object). I suggest using a tool like [discohook](https://discohook.org) and then copying the JSON content. `~send-embed-json <channel> <json-embed>`

#### Editing rich embeds

Two options as above, both take the same content.

{% hint style="warning" %}
Trying to edit a message without an embed will result in an error.
{% endhint %}

**Editing basic embeds**

This will update only the title and description of the embed in the message provided. Any other content is ingored.\
`~edit-embed <channel> <message>` The title and description will be prompted

**Editing full embeds**

Provide the JSON form of the new embed, the format can be found in the sending [section](https://github.com/AnotherCat/message-bot/tree/f010987eadbcd5ab0de44aeeb7357fd53acc316f/README.md#full-embeds)\
I suggest fetching the JSON version of the original embed and then editing it to use in this command.\
`~edit-embed-json <channel> <message> <json-embed>`

### Fetching messages

When you 'fetch' a message it will return a `.txt` or `.json` file depending on the type of message. If the message is an embed the bot will send a `.json` file with the JSON representation of the embed.\
This is useful because it mean that you can view and change the exact content that the bot handles without any of discord's formatting.

`~fetch <channel> <message id>`\
Alias: `~fetch-embed`

{% code title="Content.txt" %}

```
Content:

This message was edited!
```

{% endcode %}

### Deleting messages

The bot can delete messages that it has sent. This is useful in situations where you don't have the `MANAGE MESSAGES` permission.\
You will be prompted to confirm the deletion

{% hint style="info" %}
A `.txt` file will be returned if the content is too long, or a `.json` file if the message was an embed.
{% endhint %}

`~delete <channel> <message id>`\
Alias: `~delete-embed`

![Deleting a message](https://1355931420-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MDrSfgrxH3dw9lmECOD%2Fsync%2F5b7ac14c9a87d68d548564346554eae05ef7e353.png?generation=1601333484692317\&alt=media)
