From 61974411dff260a5786d90451c8917af4eb96ef0 Mon Sep 17 00:00:00 2001 From: Josh Date: Sat, 19 Feb 2022 14:00:52 +1000 Subject: [PATCH] [commands] Fix issue in PartialMessageConverter._resolve channel --- discord/ext/commands/converter.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/discord/ext/commands/converter.py b/discord/ext/commands/converter.py index 5740a188e..f314a57df 100644 --- a/discord/ext/commands/converter.py +++ b/discord/ext/commands/converter.py @@ -353,14 +353,17 @@ class PartialMessageConverter(Converter[discord.PartialMessage]): @staticmethod def _resolve_channel(ctx, guild_id, channel_id) -> Optional[PartialMessageableChannel]: + if channel_id is None: + # we were passed just a message id so we can assume the channel is the current context channel + return ctx.channel + if guild_id is not None: guild = ctx.bot.get_guild(guild_id) - if guild is not None and channel_id is not None: - return guild._resolve_channel(channel_id) # type: ignore - else: + if guild is None: return None - else: - return ctx.bot.get_channel(channel_id) if channel_id else ctx.channel + return guild._resolve_channel(channel_id) + + return ctx.bot.get_channel(channel_id) async def convert(self, ctx: Context, argument: str) -> discord.PartialMessage: guild_id, message_id, channel_id = self._get_id_matches(ctx, argument)