-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathreact_decorators.py
More file actions
30 lines (24 loc) · 912 Bytes
/
react_decorators.py
File metadata and controls
30 lines (24 loc) · 912 Bytes
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
import functools
from discord.ext.commands import Context
def wait_react(func):
@functools.wraps(func)
async def decorator(*args, **kwargs):
ctx: Context = next(a for a in args if isinstance(a, Context))
await ctx.message.add_reaction("🕐")
await func(*args, **kwargs)
await ctx.message.remove_reaction("🕐", ctx.me)
return decorator
def done_react(func):
@functools.wraps(func)
async def decorator(*args, **kwargs):
ctx: Context = next(a for a in args if isinstance(a, Context))
await func(*args, **kwargs)
await ctx.message.add_reaction("👍")
return decorator
def remove_command(func):
@functools.wraps(func)
async def decorator(*args, **kwargs):
ctx: Context = next(a for a in args if isinstance(a, Context))
await func(*args, **kwargs)
await ctx.message.delete()
return decorator