Total Complexity | 3 |
Total Lines | 39 |
Duplicated Lines | 0 % |
Changes | 0 |
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 |