(discord.py)如何在DM中显示漫游器类型指示器

时间:2020-06-10 19:30:19

标签: python python-3.x discord discord.py

我听说ctx.typing()存在,但我希望我的机器人在DM中显示指示器。到目前为止,这是我的代码:

@client.event
async def on_message(message):
    await client.process_commands(message)
    # i want the bot to display 'typing...' for 1 second
    if message.guild is None and not message.author.bot:
        with open('dmresponses.txt') as input_file:
            long_list = [line.strip() for line in input_file]
        await message.author.send(random.choice(long_list))

我该如何实现?

1 个答案:

答案 0 :(得分:1)

这可以通过 <script> import{Line} from 'vue-chartjs'; import {mapGetters,mapActions} from 'vuex'; export default { extends:Line, data: () => ({ chartdata: { labels: ['January', 'February'], datasets: [ { label: 'Data One', backgroundColor: '#f87979', data: this.currentDeath } ] }, options: { responsive: true, maintainAspectRatio: false } }), methods:{ ...mapActions(["fetchData"]), }, computed:{ ...mapGetters(["currentDeath"]) }, created(){ this.fetchData() }, mounted(){ const dates = this. this.renderChart(this.chartData,this.options) } } </script> <style scoped> </style> 上下文管理器来实现:

typing()

如果您想强调打字时长,可以使用@client.event async def on_message(message): await client.process_commands(message) if message.guild is None and not message.author.bot: async with message.channel.typing(): with open("dmresponses.txt") as input_file: # do stuff inside long_list = [line.strip() for lin in input_file] await message.author.send(random.choice(long_list)) # what to do after typing 来添加延迟:

asyncio.sleep()

参考: