python - discord.py 简单命令不起作用(在 pythonista 中)
问题描述
我刚刚开始使用 Pythonista 中的 discord.py 机器人,但我不确定为什么这个起始代码(从官方文档复制)不起作用 - 当我输入“!test hello”时,机器人没有回复,而当我之前使用“on_message”时,它工作得很好。当我在笔记本电脑上的 PyCharm 中尝试它时,它也不起作用。任何帮助表示赞赏。谢谢!
import discord
from discord.ext import commands
bot = commands.Bot(command_prefix='!')
@bot.command()
async def test(ctx, arg):
await ctx.send(arg)
bot.run("myToken")
解决方案
由于我真的没有看到问题,也许你可以尝试更新 discord.py 做pip install -U discord.py
推荐阅读
- rust - 为什么直接从 println 调用时内联汇编的系统调用会执行两次,但存储在临时变量中时不会?
- javascript - 如何根据页面上存在的元素跳过显示某些内容或不使用 javascript 或做出反应?
- sql - 按年和月排序
- flutter - 颤动中的滚动完成回调
- javascript - 参数中的值在方法之后没有保持其值
- python - 如何在 python 中转换特殊字符的编码?
- python - 在分配全局之前引用的局部变量不起作用
- python - 找到适合多个参数的函数
- php - 在 zend-expressive-hal 配置中将选项传递给 ClassMethodsHydrator
- .net - msix 和多个目标框架不起作用