我正在使用Discord模块制作一个Discord机器人。我对此很不好,因为我不久前才开始编码。好吧,我在设置机器人的前缀时遇到了一些问题:它说在第8行中有一个错误。unclosed client session
和NameError: name 'command' is not defined
也是如此。
这是错误:
Traceback (most recent call last):
File "SUBLIME TEXT PRUEBA.py", line 8, in <module>
client = command.Bot(command_prefix = '!')
NameError: name 'command' is not defined
Unclosed client session
client_session: <aiohttp.client.ClientSession object at 0x0000017638A4F9E8>
我还将把代码放在这里...
import discord
from discord.ext.commands import Bot
from discord.ext import commands
import asyncio
Client = discord.Client()
client = command.Bot(command_prefix = '!')
@client.event
async def on_ready():
print('bot is redey')
@client.event
async def on_message(message):
if message.content == 'keke':
await client.send_message(message.channel, 'KEKEKEKEKK')
答案 0 :(得分:2)
如评论中所述:
commands
而不是command
discord.Client()
会话可能需要使用close()
之类的方法关闭