Fix error when no valid messages can be found for selection
This commit is contained in:
3
bot.py
3
bot.py
@@ -123,6 +123,9 @@ async def random_message_command(ctx: commands.Context, channel: Optional[discor
|
|||||||
channel = ctx.channel
|
channel = ctx.channel
|
||||||
messages = async_filter(_is_message_allowed_for_operations, channel.history(limit=max_cnt))
|
messages = async_filter(_is_message_allowed_for_operations, channel.history(limit=max_cnt))
|
||||||
messages = [item async for item in messages]
|
messages = [item async for item in messages]
|
||||||
|
if not messages:
|
||||||
|
await ctx.channel.send("No valid messages found!")
|
||||||
|
return
|
||||||
msg: discord.Message = random.choice(messages)
|
msg: discord.Message = random.choice(messages)
|
||||||
author: discord.abc.User = msg.author
|
author: discord.abc.User = msg.author
|
||||||
embed = discord.Embed(
|
embed = discord.Embed(
|
||||||
|
|||||||
Reference in New Issue
Block a user