我目前正在开发使用Python编程语言编写的Discord机器人。我看过一些教程,导致我自己无法使用它,并且我注意到所有人都使用Client = discord.Client() 导入运行程序所需的文件后的命令。当我尝试运行该应用程序时,它说
Traceback (most recent call last):
File "C:\Users\Admin\Desktop\testbot.py", line 2, in <module>
import discord.client
ModuleNotFoundError: No module named 'discord.client'
如果有人有任何建议,请回复并告诉我! 谢谢!
这是我给机器人的代码!
import discord
Client = discord.Client()
@client.event
async def on_ready():
print ("Bot is ready!")
@client.event
async def on_message(message):
if message.content == '/testconnection':
await client.send_message(message.channel, "Connection successfully established with Discord NET")
@client.event
async def on_ready():
print('Logged in as')
print(client.user.name)
print(client.user.id)
print('-------')
client.run("my discord bot token goes here but i'm hiding it ")
答案 0 :(得分:1)
import discord.client
此行不在您发布的代码中的任何地方出现。
您正在将discord.Client()
分配给Client
,但是在其余代码中使用了client
。名称区分大小写,因此您应将该行更改为
client = discord.Client()