【发布时间】:2020-11-27 00:49:40
【问题描述】:
我是 discord py 和 asyncio 的新手。我希望机器人在循环内运行该函数五次。
from discord.ext import commands
Bot = commands.Bot(command_prefix= '!')
a=0
@Bot.event
async def on_ready():
print('Bot online')
@Bot.command()
async def msg(ctx):
global a
a=a+1
await ctx.author.send(a)
for i in range(5):
msg()
Bot.run('token')
不幸的是,如果没有在频道中手动输入命令 (!msg),这将不起作用。此外,它不会循环执行。如何调用discord函数作为标准python函数?
【问题讨论】:
标签: python python-3.x discord python-asyncio discord.py