diff options
author | 2022-04-19 12:21:16 +0100 | |
---|---|---|
committer | 2022-04-19 12:23:16 +0100 | |
commit | 72274ce3e768521b9acc5490477b2a8edfc3b6a5 (patch) | |
tree | 07b01217273a6ce86be39fb91a22c2e4d1a05add | |
parent | Don't pass unused param to infraction scheduler cog_load (diff) |
channel.history is now an async iterator, so has no .next() method
-rw-r--r-- | bot/exts/help_channels/_message.py | 3 | ||||
-rw-r--r-- | bot/exts/moderation/incidents.py | 2 |
2 files changed, 3 insertions, 2 deletions
diff --git a/bot/exts/help_channels/_message.py b/bot/exts/help_channels/_message.py index f4c3a6fd7..40bec74a5 100644 --- a/bot/exts/help_channels/_message.py +++ b/bot/exts/help_channels/_message.py @@ -67,7 +67,8 @@ async def get_last_message(channel: discord.TextChannel) -> t.Optional[discord.M log.trace(f"Getting the last message in #{channel} ({channel.id}).") try: - return await channel.history(limit=1).next() # noqa: B305 + async for message in channel.history(limit=1): + return message except StopAsyncIteration: log.debug(f"No last message available; #{channel} ({channel.id}) has no messages.") return None diff --git a/bot/exts/moderation/incidents.py b/bot/exts/moderation/incidents.py index c0bd09b72..b65f9262f 100644 --- a/bot/exts/moderation/incidents.py +++ b/bot/exts/moderation/incidents.py @@ -183,7 +183,7 @@ async def make_message_link_embed(ctx: Context, message_link: str) -> Optional[d except MessageNotFound: mod_logs_channel = ctx.bot.get_channel(Channels.mod_log) - last_100_logs: list[discord.Message] = await mod_logs_channel.history(limit=100).flatten() + last_100_logs: list[discord.Message] = [message async for message in mod_logs_channel.history(limit=100)] for log_entry in last_100_logs: if not log_entry.embeds: |