aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar ToxicKidz <[email protected]>2022-03-15 11:08:07 -0400
committerGravatar GitHub <[email protected]>2022-03-15 11:08:07 -0400
commit39deb2b4bd586618a3aa87c47b5e00d7b321d260 (patch)
treef0dd6f96660159e5d9a1fc6ebff513d274feb69c
parentMerge pull request #2113 from python-discord/revert-disnake (diff)
parentMerge branch 'main' into fix-issue-1930 (diff)
Merge pull request #2087 from python-discord/fix-issue-1930
Allow duckifying of messages in threads
-rw-r--r--bot/exts/fun/duck_pond.py20
1 files changed, 6 insertions, 14 deletions
diff --git a/bot/exts/fun/duck_pond.py b/bot/exts/fun/duck_pond.py
index c51656343..8a41a3116 100644
--- a/bot/exts/fun/duck_pond.py
+++ b/bot/exts/fun/duck_pond.py
@@ -2,7 +2,7 @@ import asyncio
from typing import Union
import discord
-from discord import Color, Embed, Message, RawReactionActionEvent, TextChannel, errors
+from discord import Color, Embed, Message, RawReactionActionEvent, errors
from discord.ext.commands import Cog, Context, command
from bot import constants
@@ -46,17 +46,6 @@ class DuckPond(Cog):
return True
return False
- @staticmethod
- def is_helper_viewable(channel: TextChannel) -> bool:
- """Check if helpers can view a specific channel."""
- guild = channel.guild
- helper_role = guild.get_role(constants.Roles.helpers)
- # check channel overwrites for both the Helper role and @everyone and
- # return True for channels that they have permissions to view.
- helper_overwrites = channel.overwrites_for(helper_role)
- default_overwrites = channel.overwrites_for(guild.default_role)
- return default_overwrites.view_channel is None or helper_overwrites.view_channel is True
-
async def has_green_checkmark(self, message: Message) -> bool:
"""Check if the message has a green checkmark reaction."""
for reaction in message.reactions:
@@ -165,12 +154,15 @@ class DuckPond(Cog):
if not self._payload_has_duckpond_emoji(payload.emoji):
return
- channel = discord.utils.get(self.bot.get_all_channels(), id=payload.channel_id)
+ await self.bot.wait_until_guild_available()
+ guild = self.bot.get_guild(payload.guild_id)
+ channel = guild.get_channel_or_thread(payload.channel_id)
if channel is None:
return
# Was the message sent in a channel Helpers can see?
- if not self.is_helper_viewable(channel):
+ helper_role = guild.get_role(constants.Roles.helpers)
+ if not channel.permissions_for(helper_role).view_channel:
return
try: