猿问

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

我正在使用 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')


哔哔one
浏览 173回答 1
1回答

饮歌长啸

正如评论中所讨论的:你需要使用commands而不是command您的discord.Client()会话需要关闭,可能使用类似的方法close()
随时随地看视频慕课网APP

相关分类

Python
我要回答