Add trigger typing to random message
This commit is contained in:
2
bot.py
2
bot.py
@@ -117,6 +117,7 @@ async def on_message(message: discord.Message):
|
|||||||
@bot.command(name='random_message', brief='Select a random message from a channel')
|
@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,
|
async def random_message_command(ctx: commands.Context, channel: Optional[discord.TextChannel] = None,
|
||||||
max_cnt: int = 100):
|
max_cnt: int = 100):
|
||||||
|
typing = ctx.channel.trigger_typing()
|
||||||
if channel is None:
|
if channel is None:
|
||||||
channel = ctx.channel
|
channel = ctx.channel
|
||||||
messages = await channel.history(limit=max_cnt).flatten()
|
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_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")
|
embed.set_footer(text="random message from #" + channel.name + " out of " + str(len(messages)) + " messages")
|
||||||
|
await typing
|
||||||
await ctx.channel.send(embed=embed)
|
await ctx.channel.send(embed=embed)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user