cogs   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 3
eloc 27
dl 0
loc 36
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A OnReadyCog.on_ready() 0 5 1
A ErrorHandler.on_command_error() 0 14 1
A SayCog.say() 0 3 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