# Reaction Manager

## ReactionManager

#### **class discordSuperUtils.**&#x52;eactionManage&#x72;**(database, table, bot)**

Initializer of [**`ReactionManager`**](#reactionmanager), represents a reaction manager that manages reactions. Inherits [**`EventManager`**](https://discord-super-utils.gitbook.io/discord-super-utils/base#eventmanager).

{% hint style="warning" %}
All inherited methods and attributes from[ **EventManager**](https://discord-super-utils.gitbook.io/discord-super-utils/base#eventmanager) are unlisted.
{% endhint %}

| [**Attributes**](https://discord-super-utils.gitbook.io/discord-super-utils/page-manager#attributes) | [**Methods**](https://discord-super-utils.gitbook.io/discord-super-utils/page-manager#methods) | [**Events**](#events)   |
| ---------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------- | ----------------------- |
| **`database`**                                                                                       | **`format_data`**                                                                              | **`on_reaction_event`** |
| **`table`**                                                                                          | **`checks`**                                                                                   |                         |
| **`bot`**                                                                                            | **`create_reaction`**                                                                          |                         |
|                                                                                                      | **`delete_reaction`**                                                                          |                         |

### Attributes

* **`database` (**[**DatabaseManager**](https://discord-super-utils.gitbook.io/discord-super-utils/database-manager#databasemanager)**)**

  * The database the reaction manager will work on.&#x20;
  * Passed in initializer.

* **`table` (str)**

  * The database table the reaction manager will work on.&#x20;
  * Passed in initializer.

* **`bot` (commands.Bot)**
  * The bot that the reaction manager will work on.
  * Passed in initializer.

### Methods

* **`format_data()`**

  **Formats** **data** into an organized dict.\
  This function is a classmethod (static).\
  \
  **Parameters**

  * **`data` (list)**
    * &#x20;Data to format.

* **`checks(guild_id, message_id, emoji)`**\
  Returns a dictionary of **checks** that are used as database **checks**.\
  This function is a classmethod (static).\
  \
  **Parameters**
  * **`guild_id` (int)**
    * The value of the guild key.
  * **`message_id` (int)**
    * The value of the message key.
  * **`emoji` (str)**

    * The value of the emoji key.

* **`create_reaction(guild, message, role, emoji, remove_on_reaction)`**\
  Creates a reaction role and saves it in the database.\
  A record wont be created if a record with the same values already exists.\
  \
  **Parameters**

  * **`guild` (discord.Guild)**
    * The guild of the reaction role.
  * **`message` (discord.Message)**
    * The message of the reaction role.
  * **`role` (discord.Role)**

    * The role of the reaction role.
    * If `None`, calls on-reaction-event.

  **Raises**

  * **EmojiError**

    * Cannot add reaction to message.

* **`delete_reaction(guild, message, emoji)`**\
  **Deletes** a reaction role from the database.\
  \
  **Parameters**
  * **`guild` (discord.Guild)**
    * The guild of the reaction role.
  * **`message` (discord.Message)**
    * The message of the reaction role.
  * **`emoji` (str)**
    * The emoji of the reaction role.

### **Events**

* **`on_reaction_event(guild, channel, message, member, emoji)`**\
  This event is called if a **reaction role** is triggered but **role** is `None`.\
  \
  **Parameters**
  * **`guild` (discord.Guild)**
    * The guild of the reaction role.
  * **`channel` (discord.TextChannel)**
    * The channel of the reaction role.
  * **`message` (discord.Message)**
    * The message of the reaction role.
  * **`member` (discord.Member)**
    * The reaction member.
  * **`emoji` (str)**
    * The emoji of the reaction role.
