Add trigger typing to random message

This commit is contained in:
2020-12-19 03:02:46 +01:00
parent 38d10c5c9d
commit e101c81a1e

2
bot.py
View File

@@ -117,6 +117,7 @@ async def on_message(message: discord.Message):
@bot.command(name='random_message', brief='Select a random message from a channel')
async def random_message_command(ctx: commands.Context, channel: Optional[discord.TextChannel] = None,
max_cnt: int = 100):
typing = ctx.channel.trigger_typing()
if channel is None:
channel = ctx.channel
messages = await channel.history(limit=max_cnt).flatten()
@@ -127,6 +128,7 @@ async def random_message_command(ctx: commands.Context, channel: Optional[discor
)
embed.set_author(name=author.display_name, icon_url=author.avatar_url)
embed.set_footer(text="random message from #" + channel.name + " out of " + str(len(messages)) + " messages")
await typing
await ctx.channel.send(embed=embed)