# Cogs

### Help

{% hint style="info" %}
A [cog](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#cog) which implement help commands and methods to build the help message.
{% endhint %}

```python
import discord
from discord_slash import SlashCommand
from baseDiscord import BaseBot, Help

mybot = BaseBot("my token", prefix="!", color=discord.Colour.blue(), color_error=discord.Colour.red())
slash = SlashCommand(mybot)

# Add cogs
Help.setup(bot)
```

#### Parameters

```python
Help.__init__(self, bot: commands.Bot, max_cmd_by_page: int = 8)
```

| Parameter         |                                                 Type                                                | Description                                                             | Required | Default |
| ----------------- | :-------------------------------------------------------------------------------------------------: | ----------------------------------------------------------------------- | :------: | :-----: |
| `bot`             | [*discord.ext.commands.Bot*](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#bots) | The Bot instance which use the cog                                      |    ✔️    |         |
| `max_cmd_by_page` |                                                *int*                                                | The maximum of commands by help page. Used for the global help command. |     ❌    |   `8`   |

#### Attributes

Attributes of [`discord.ext.commands.Cog`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#cog) +

| Name              |                                                 Type                                                | Description                                                             |
| ----------------- | :-------------------------------------------------------------------------------------------------: | ----------------------------------------------------------------------- |
| `bot`             | [*discord.ext.commands.Bot*](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#bots) | The Bot instance which use the cog                                      |
| `max_cmd_by_page` |                                                *int*                                                | The maximum of commands by help page. Used for the global help command. |

#### Methods

Methods of Cog +

* \_`base_embed` : a method to create a base [embed](https://discordpy.readthedocs.io/en/latest/api.html#embed) for help commands. This [embed](https://discordpy.readthedocs.io/en/latest/api.html#embed) is created with a thumbnail.
  * **Parameters**
    * `title` :  *str* - The title of Embed
    * (`description`) : *str* - The description of Embed
    * (`author`) : *discord.User* - author of Embed
  * **Returns**
    * `embed` : [*discord.Embed* ](https://discordpy.readthedocs.io/en/latest/api.html#embed)- the embed instance

{% hint style="info" %}
The method `base_embed`can be use to create an[ Embed](https://discordpy.readthedocs.io/en/latest/api.html#embed) with avatar of bot in thumbnail and the author of command.
{% endhint %}

* `_command_base` : a method to create a base help for a command. Used for the global help command.
  * **Paramters**
    * `cmd` : [*discord.ext.commands.Command*](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#command) - The command
  * **Returns**
    * *str* - The base help for the command. By default, included the description, the name and the brief of command.
* `_command_usage` : a method to create an usage message for a command
  * **Parameters**
    * `cmd` : [*discord.ext.commands.Command*](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#command) - The command
  * **Returns :** *str* - usage of the command if it's exist else an empty string.
* `_command_aliases` : a method to create aliases message for a command.
  * **`Parameters`**
    * `cmd` : [*discord.ext.commands.Command*](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#command) - The command
  * **Returns :** *str* - aliases of the command if it's exist else an empty string.
* `_command_help_fmt` : method to format the help message for a command. This method join the result of `_command_base`, `_command_usage and _command_aliases` methods.
  * **`Parameters`**
    * `cmd` : [*discord.ext.commands.Command*](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#command) - The command
  * **Returns :** *str* - The help message for the command

{% hint style="info" %}
:arrow\_up: These methods can be overwrite to customize the help message of a command.
{% endhint %}

* `first_page` : method to create the first page (embed) of global help command
  * **Parameters**
    * (author) : [discord.User](https://discordpy.readthedocs.io/en/latest/api.html#id7) - The author of command
  * **Returns :** [*discord.Embed* ](https://discordpy.readthedocs.io/en/latest/api.html#embed) - embed for the first page of global help commands

{% hint style="info" %}
To customize the first page of help command. You can overwrite the `first_page` method. This method must returns an [Embed](https://discordpy.readthedocs.io/en/latest/api.html#embed).
{% endhint %}

* `commands_pages` : method to create the help pages (embed) for commands
  * Parameters
    * group\_cmd : *Union\[*[*Cog*](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#cog) *, List\[*[*Command*](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#command)*]]* - The cog or a list of commands for the help commands (it's a group of commands for a same "category").
    * (author) :  [discord.User](https://discordpy.readthedocs.io/en/latest/api.html#id7) - The author of command.
  * Returns : List\[[*discord.Embed* ](https://discordpy.readthedocs.io/en/latest/api.html#embed)] - The list of page (embed) for this group of commands.

{% hint style="info" %}
To customize the structure of pages for the help command. You can overwrite the method. This method must  returns a list of [Embed](https://discordpy.readthedocs.io/en/latest/api.html#embed).
{% endhint %}

#### &#x20;Commands

{% hint style="warning" %}
There is not commands
{% endhint %}

#### Slash Commands

* **help**
  * **`all`** : Show a help on all commands in an embed multi pages. This commands use `first_page` and `commands_pages to build pages.`
  * **`command`**` ``:`Get help for a scpecific command.
  * **`category`** : Get help for a category of commands

{% hint style="info" %}
Commands which have the attribute `hidden = True` aren't displayed.
{% endhint %}

{% hint style="warning" %}
You shouldn't overwrite the method which implement this command.
{% endhint %}

{% hint style="danger" %}
Subcommands `command` and `category` are not implemented.
{% endhint %}

### Owner

{% hint style="info" %}
A [cog](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#cog) which implement utils commands for the application's owner.
{% endhint %}

```python
import discord
from discord_slash import SlashCommand
from baseDiscord import BaseBot, Owner

mybot = BaseBot("my token", prefix="!", color=discord.Colour.blue(), color_error=discord.Colour.red())
slash = SlashCommand(mybot)

# Add cogs
Owner.setup(bot)
```

#### Parameters

```python
Owner.__init__(self, bot: commands.Bot)
```

| `Parameter` |                                                 Type                                                | Description                        | Required | Default |
| ----------- | :-------------------------------------------------------------------------------------------------: | ---------------------------------- | :------: | ------- |
| `bot`       | [*discord.ext.commands.Bot*](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#bots) | The Bot instance which use the cog |    ✔️    |         |

#### Attributes

Attributes of [`discord.ext.commands.Cog`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#cog) +

| Name |                                                 Type                                                | Description                        |
| ---- | :-------------------------------------------------------------------------------------------------: | ---------------------------------- |
| bot  | [*discord.ext.commands.Bot*](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#bots) | The Bot instance which use the cog |

#### Methods

#### Commands

* **`stopBot`** : A command to disconnect the bot.

{% hint style="info" %}
All commands of this [Cog](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#cog) are created with attribute `hidden=True`
{% endhint %}

#### Slash Commands

{% hint style="warning" %}
There is not slash commands
{% endhint %}
