为了账号安全,请及时绑定邮箱和手机立即绑定

未关闭的客户端会话。有什么解决办法吗?

未关闭的客户端会话。有什么解决办法吗?

哔哔one 2021-08-17 16:24:38
我正在使用 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 definedUnclosed client sessionclient_session: <aiohttp.client.ClientSession object at 0x0000017638A4F9E8>我也要把代码放在这里...import discordfrom discord.ext.commands import Botfrom discord.ext import commandsimport asyncioClient = discord.Client()client = command.Bot(command_prefix = '!')@client.eventasync def on_ready():    print('bot is redey')@client.eventasync def on_message(message):    if message.content == 'keke':        await client.send_message(message.channel, 'KEKEKEKEKK')
查看完整描述

1 回答

?
饮歌长啸

TA贡献1951条经验 获得超3个赞

正如评论中所讨论的:

  • 你需要使用commands而不是command

  • 您的discord.Client()会话需要关闭,可能使用类似的方法close()


查看完整回答
反对 回复 2021-08-17
  • 1 回答
  • 0 关注
  • 172 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号