@@ -20,31 +20,27 @@ def reaction_check(
20
20
user : discord .abc .User ,
21
21
* ,
22
22
message_id : int ,
23
- allowed_emoji : Sequence [str ],
23
+ allowed_emojis : Sequence [str ],
24
24
allowed_users : Sequence [int ],
25
- mod_roles : Sequence [int ],
26
- allow_mods : bool = True ,
25
+ allowed_roles : Sequence [int ],
27
26
) -> bool :
28
27
"""
29
- Check if a reaction's emoji and author are allowed and the message is `message_id` .
28
+ Checks if a reaction's emoji and author are allowed.
30
29
31
- If the user is not allowed, remove the reaction. Ignore reactions made by the bot.
32
- If `allow_mods` is True, allow users with `mod_roles` even if they're not in `allowed_users`.
30
+ A reaction's emoji is allowed when it's not by a bot, is on `message_id`, and in `allowed_emojis`.
31
+ A user is allowed when their id is in `allowed_users`, or they have a role that's in `allowed_roles`.
32
+
33
+ If the user is not allowed, removes the reaction.
33
34
"""
34
35
right_reaction = (
35
36
not user .bot
36
37
and reaction .message .id == message_id
37
- and str (reaction .emoji ) in allowed_emoji
38
+ and str (reaction .emoji ) in allowed_emojis
38
39
)
39
40
if not right_reaction :
40
41
return False
41
42
42
- is_moderator = (
43
- allow_mods
44
- and any (role .id in mod_roles for role in getattr (user , "roles" , []))
45
- )
46
-
47
- if user .id in allowed_users or is_moderator :
43
+ if user .id in allowed_users or any (role .id in allowed_roles for role in getattr (user , "roles" , [])):
48
44
log .trace (f"Allowed reaction { reaction } by { user } on { reaction .message .id } ." )
49
45
return True
50
46
else :
@@ -60,22 +56,21 @@ def reaction_check(
60
56
async def wait_for_deletion (
61
57
bot : commands .Bot ,
62
58
message : discord .Message ,
63
- user_ids : Sequence [int ],
64
- mod_roles : Sequence [int ],
59
+ * ,
60
+ allowed_users : Sequence [int ],
61
+ allowed_roles : Sequence [int ],
65
62
deletion_emojis : Sequence [str ] = ("<:trashcan:675729438528503910>" ,),
66
63
timeout : float = 60 * 5 ,
67
64
attach_emojis : bool = True ,
68
- allow_mods : bool = True
69
65
) -> None :
70
66
"""
71
- Wait for any of `user_ids` to react with one of the `deletion_emojis` within `timeout` seconds to delete `message`.
67
+ Waits for an allowed user to react with one of the `deletion_emojis` within `timeout` seconds to delete `message`.
68
+
69
+ A user is defined as allowed if their id is in `allowed_users`, or they have a role that's in `allowed_roles`.
72
70
73
71
If `timeout` expires then reactions are cleared to indicate the option to delete has expired.
74
72
75
- An `attach_emojis` bool may be specified to determine whether to attach the given
76
- `deletion_emojis` to the message in the given `context`.
77
- An `allow_mods` bool may also be specified to allow anyone with a role in `mod_roles` to delete
78
- the message.
73
+ An `attach_emojis` bool may be provided to determine whether to attach the given `deletion_emojis` to the `message`.
79
74
"""
80
75
if message .guild is None :
81
76
raise ValueError ("Message must be sent on a guild" )
@@ -92,9 +87,8 @@ async def wait_for_deletion(
92
87
reaction_check ,
93
88
message_id = message .id ,
94
89
allowed_emoji = deletion_emojis ,
95
- allowed_users = user_ids ,
96
- mod_roles = mod_roles ,
97
- allow_mods = allow_mods ,
90
+ allowed_users = allowed_users ,
91
+ allowed_roles = allowed_roles ,
98
92
)
99
93
100
94
try :
0 commit comments