Passed
Pull Request — main (#389)
by
unknown
03:10 queued 01:27
created

cogs   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 3
eloc 29
dl 0
loc 39
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 16 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(
21
            "Exception:",
22
            f"```\n{type(error).__name__}:\n{error}\n```"
23
        )
24
25
26
class OnReadyCog(Cog):
27
    @Client.event
28
    async def on_ready(self):
29
        print(
30
            f"Started client on {self.client.bot}\n"
31
            "Registered commands: " + ", ".join(self.client.chat_commands)
32
        )
33
34
35
class SayCog(Cog):
36
    @command(description="Say something as the bot!")
37
    async def say(self, ctx: MessageContext, message: str):
38
        return Embed(description=f"{ctx.author.mention} said:\n{message}")
39