File tree Expand file tree Collapse file tree 1 file changed +24
-0
lines changed
Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Original file line number Diff line number Diff line change 1+ from discord .ext import commands
2+
3+ def has_permissions (** perms ):
4+ """Check if the author has required permissions.
5+ This will always return ``True`` if the author is a bot owner, or
6+ has the ``administrator`` permission.
7+ """
8+ async def predicate (ctx ):
9+ if await ctx .bot .is_owner (ctx .author ):
10+ return True
11+
12+ resolved = ctx .channel .permissions_for (ctx .author )
13+
14+ return resolved .administrator or all (
15+ getattr (resolved , name , None ) == value for name , value in perms .items ()
16+ )
17+
18+ return commands .check (predicate )
19+
20+ def thread_only ():
21+ """Checks if the command is being run in a modmail thread"""
22+ async def predicate (ctx ):
23+ return ctx .thread is not None
24+ return commands .check (predicate )
You can’t perform that action at this time.
0 commit comments