-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathpe_decorators.py
More file actions
39 lines (23 loc) · 1.02 KB
/
pe_decorators.py
File metadata and controls
39 lines (23 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import discord
import pe_global_objects as pe_global
from typing import Callable
from inspect import signature
from functools import wraps
import traceback
from rich.console import Console
console = Console(record=True)
def command(func: Callable):
@wraps(func)
async def phi(ctx, *args, **kwargs):
channel = pe_global.bot.get_channel(pe_global.TESTING_CHANNEL_TO_ANNOUNCE)
await channel.send(func.__name__)
try:
result = await func(ctx, *args, **kwargs)
except Exception as exc:
exception_name = exc.__class__.__name__
await channel.send(exception_name)
console.log(exc, traceback.format_exc())
message = f"Could not process query because of a `{exception_name}` error, you can spam <@439143335932854272> and tell him he's a bad programmer. (If it's an `EulerRequestFail`, then a `/update` might solve the issue.)"
return await ctx.respond(message)
return result
return phi