File tree Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Original file line number Diff line number Diff line change 1
1
import functools
2
2
import discord
3
3
from discord .ext import commands
4
+ import asyncio
4
5
5
6
def trigger_typing (func ):
6
7
@functools .wraps (func )
@@ -26,4 +27,14 @@ def owner_only():
26
27
async def predicate (ctx ):
27
28
allowed = [int (x ) for x in str (ctx .bot .config .get ('owners' , '0' )).split (',' )]
28
29
return ctx .author .id in allowed
29
- return commands .check (predicate )
30
+ return commands .check (predicate )
31
+
32
+ def asyncexecutor (loop = None , executor = None ):
33
+ loop = loop or asyncio .get_event_loop ()
34
+ def decorator (func ):
35
+ @functools .wraps (func )
36
+ def wrapper (* args , ** kwargs ):
37
+ partial = functools .partial (func , * args , ** kwargs )
38
+ return loop .run_in_executor (executor , partial )
39
+ return wrapper
40
+ return decorator
You can’t perform that action at this time.
0 commit comments