aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Chris Lovering <[email protected]>2022-04-20 22:06:16 +0100
committerGravatar Chris Lovering <[email protected]>2022-04-20 22:06:16 +0100
commitb9a6c9e76cd9d79d1fff18e4e13a8948256dc267 (patch)
tree35d2339cc710b31ff90acf4d020f61c1aa629f33
parentAutomatically determine number threads to use with pytest (diff)
Refactor a try/except that will never raise
-rw-r--r--bot/exts/help_channels/_message.py11
1 files changed, 5 insertions, 6 deletions
diff --git a/bot/exts/help_channels/_message.py b/bot/exts/help_channels/_message.py
index 8eb4ec311..128fa847b 100644
--- a/bot/exts/help_channels/_message.py
+++ b/bot/exts/help_channels/_message.py
@@ -66,12 +66,11 @@ async def get_last_message(channel: discord.TextChannel) -> t.Optional[discord.M
"""Return the last message sent in the channel or None if no messages exist."""
log.trace(f"Getting the last message in #{channel} ({channel.id}).")
- try:
- 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
+ async for message in channel.history(limit=1):
+ return message
+
+ log.debug(f"No last message available; #{channel} ({channel.id}) has no messages.")
+ return None
async def is_empty(channel: discord.TextChannel) -> bool: