File tree Expand file tree Collapse file tree 1 file changed +41
-4
lines changed
Expand file tree Collapse file tree 1 file changed +41
-4
lines changed Original file line number Diff line number Diff line change 11from discord .ext import commands
22
3+
34def 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.
75 """
6+ A decorator that checks if the author has the required permissions.
7+
8+ Examples
9+ --------
10+ @has_permissions(administrator=True)
11+ async def setup(ctx):
12+ print("Success")
13+ """
14+
815 async def predicate (ctx ):
16+ """
17+ Parameters
18+ ----------
19+ ctx : Context
20+ The current discord.py `Context`.
21+
22+ Returns
23+ -------
24+ True
25+ If the author is a bot owner, or
26+ has the ``administrator`` permission.
27+ Or if the author has all of the required permissions.
28+ Otherwise, `False`.
29+ """
930 if await ctx .bot .is_owner (ctx .author ):
1031 return True
1132
@@ -20,7 +41,23 @@ async def predicate(ctx):
2041
2142
2243def thread_only ():
23- """Checks if the command is being run in a modmail thread"""
44+ """
45+ A decorator that checks if the command
46+ is being ran within a Modmail thread.
47+ """
48+
2449 async def predicate (ctx ):
50+ """
51+ Parameters
52+ ----------
53+ ctx : Context
54+ The current discord.py `Context`.
55+
56+ Returns
57+ -------
58+ True
59+ if the current `Context` is within a Modmail thread.
60+ Otherwise, `False`.
61+ """
2562 return ctx .thread is not None
2663 return commands .check (predicate )
You can’t perform that action at this time.
0 commit comments