我已经开始着手一个项目来加速我对python的学习。我正在尝试重新创建一个不和谐的机器人我使用了不少,因为我已经习惯了它的功能。下面是我当前的代码
import discord
from discord import User
from discord.ext.commands import Bot
import secrets
pybot = Bot(command_prefix = "!")
@pybot.event
async def on_read():
print("Client logged in")
@pybot.command()
async def hello(*args):
print(User.display_name)
return await pybot.say("Hello, world!")
@pybot.command()
async def truck(*args):
await pybot.send_message(message.user,'Watchout for that truck!')
pybot.run(secrets.BOT_TOKEN)
即时消息试图发生的是,当有人键入命令!truck <mention user>
时,它会向提到的用户发送一条消息,并显示消息“小心卡车!”。
我得到以下错误:
Command raised an exception: NameError: name 'message' is not defined
我试着找一些例子来说明我想做什么,但是没有找到很多,或者我不理解我应该做什么。希望这不是一个类似问题的转载
谢谢。
truck中的*参数不再是discord.py命令的有效语法
检查github存储库中的Discord.py及其examples
相关问题 更多 >
编程相关推荐