Skip to content

Commit 63c0dfb

Browse files
committed
hotfix+codebase: rework verify_send_perms and allow threads
1 parent 453b1e1 commit 63c0dfb

File tree

1 file changed

+3
-9
lines changed

1 file changed

+3
-9
lines changed

lib/manager.py

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ def getopt(obj: Any, attr: tuple[str, ...] | str | list[str]) -> Any:
300300
return obj
301301

302302
@staticmethod
303-
async def verify_send_perms(channel: discord.TextChannel) -> bool:
303+
async def verify_send_perms(channel: discord.abc.Messageable | discord.abc.GuildChannel) -> bool:
304304
"""
305305
Check if the client can comfortably send a message to a channel
306306
@@ -309,14 +309,8 @@ async def verify_send_perms(channel: discord.TextChannel) -> bool:
309309
"""
310310
if isinstance(channel, discord.DMChannel):
311311
return True
312-
if isinstance(channel, discord.Thread):
313-
return False
314-
perms: list = list(iter(channel.permissions_for(channel.guild.me)))
315-
overwrites: list = list(iter(channel.overwrites_for(channel.guild.me))) # weird inspection, keep an eye on this
316-
if all(req in perms + overwrites for req in [('send_messages', True),
317-
('read_messages', True),
318-
('read_message_history', True)]) \
319-
or ('administrator', True) in perms:
312+
permissions = channel.permissions_for(channel.guild.me)
313+
if (permissions.send_messages and permissions.read_messages and permissions.read_message_history) or permissions.administrator:
320314
return True
321315
return False
322316

0 commit comments

Comments
 (0)