cogs.OnReadyCog.on_ready()   A
last analyzed

Complexity

Conditions 1

Size

Total Lines 5
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 5
dl 0
loc 5
rs 10
c 0
b 0
f 0
cc 1
nop 1
1
from typing import Any, Dict, List
2
from pincer import Client, Cog, command
3
from pincer.objects import MessageContext, Embed
4
5
6
class ErrorHandler(Cog):
7
    @Client.event
8
    async def on_command_error(
9
        self,
10
        ctx: MessageContext,
11
        error: Exception,
12
        args: List[Any],
13
        kwargs: Dict[str, Any],
14
    ):
15
        return Embed(
16
            "Oops...",
17
            "An error occurred while trying to execute the "
18
            f"`{ctx.interaction.data.name}` command! Please retry later!",
19
            color=0xFF0000,
20
        ).add_field("Exception:", f"```\n{type(error).__name__}:\n{error}\n```")
21
22
23
class OnReadyCog(Cog):
24
    @Client.event
25
    async def on_ready(self):
26
        print(
27
            f"Started client on {self.client.bot}\n"
28
            "Registered commands: " + ", ".join(self.client.chat_commands)
29
        )
30
31
32
class SayCog(Cog):
33
    @command(description="Say something as the bot!")
34
    async def say(self, ctx: MessageContext, message: str):
35
        return Embed(description=f"{ctx.author.mention} said:\n{message}")
36