早上好,
我一直坚持连接我的混乱机器人。我一直在使用 PyCharm IDE 尝试使用我创建的代码连接我的不和谐机器人。
我的代码正在查找我存储的 BOT_TokenA 和 Bot_TokenF 变量,以在不和谐中初始化该功能。
import datetime
from discord.ext import commands
import discord
from dataclasses import dataclass
import json
import os
import decouple
from discord.ext import commands
from decouple import config
#decouple is used in this line| Grabds data from env file since its considered as variable or source code
BOT_TOKEN1 = config("BOT_TOKENA")
BOT_TOKEN2 = config("BOT_TOKENF")
if __name__ == "__main__":
bot = commands.Bot(command_prefix="Angel ", intents=discord.Intents.all())
bot.run(BOT_TOKEN1)
@bot.event
async def on_ready():
print("Hello! BOT is ready")
channel = bot.get_channel(CHANNEL_ID)
await channel.send("BOT is ready!")
BOT_TOKENA=config('BOT_TOKENA')
BOT_TOKENF=config('BOT_TOKENB')
BOT_TOKEN = config('BOT_TOKEN1')
CHANNEL_ID = 1215073255233163286
CHANNEL_ID2 = 0000000000000
一旦我调试了我的代码,这就是调试器中出现的内容。与此错误关联的文件是“connector.py”文件,该文件与“aiohttp”
直接关联 async def _wrap_create_connection(
self,
*args: Any,
req: ClientRequest,
timeout: "ClientTimeout",
client_error: Type[Exception] = ClientConnectorError,
**kwargs: Any,
) -> Tuple[asyncio.Transport, ResponseHandler]:
try:
async with ceil_timeout(
timeout.sock_connect, ceil_threshold=timeout.ceil_threshold
):
return await self._loop.create_connection(*args, **kwargs)
except cert_errors as exc:
raise ClientConnectorCertificateError(req.connection_key, exc) from exc
except ssl_errors as exc:
raise ClientConnectorSSLError(req.connection_key, exc) from exc
except OSError as exc:
if exc.errno is None and isinstance(exc, asyncio.TimeoutError):
raise
raise client_error(req.connection_key, exc) from exc
来自 pycharm 的调试器信息
异常 = {元组:3}(
我需要实现什么才能让我的代码不显示此错误并将我的客户端连接到discord.com?
aiohttp.client_exceptions.ClientConnectorCertificateError:无法连接到主机discord.com:443 ssl:True [SSLCertVerificationError:(1,'[SSL:CERTIFICATE_VERIFY_FAILED]证书验证失败:无法获取本地颁发者证书(_ssl.c:1000)' )]
如有任何建议,我们将不胜感激。
对于 MacOS,在终端中输入以下行,
在终端代码中,
"pip install certif"
"/Applications/Python\ 3.12/Install\ Certificates.command"(pay attention to your version of python 3.12 could change depending on what is in your system)
第二行用于创建正确的权限,以便可以根据正确的 SSL 要求发出网络请求。