ClientConnectorError:无法连接到主机 discordapp.com:443 ssl:默认 [连接呼叫失败('162.159.134.233',443)] [英] ClientConnectorError: Cannot connect to host discordapp.com:443 ssl:default [Connect call failed ('162.159.134.233', 443)]

查看:71
本文介绍了ClientConnectorError:无法连接到主机 discordapp.com:443 ssl:默认 [连接呼叫失败('162.159.134.233',443)]的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我尝试在 Discord 中创建一个机器人,并尝试在 Gitpod 上运行我的 discord 机器人并且它能够运行,但是当我尝试在 pythonanywhere.com 上运行它时,我收到了以下错误:

So I was trying out making a bot in Discord and I tried running my discord bot over Gitpod and it was able to run, but when I tried running it on pythonanywhere.com, I get this error:

aiohttp.client_exceptions.ClientConnectorError: Cannot connect to host discordapp.com:443 ssl:default [Connect call failed ('162.159.134.233', 443)]

这是我的代码片段:

import discord
from discord.ext import commands
import json

with open("credentials.json") as creds:
    creds = json.loads(creds.read())
    TOKEN = creds["TOKEN"]

client = discord.Client()

class Bot(commands.Bot):
    def __init__(self):
        super(Bot, self).__init__(command_prefix="$", case_insensitive=True)
        self.pool = None

bot = Bot()

@bot.event
async def on_ready():
    print('Logged in as')
    print(bot.user)
    print('------')

# calculate
@bot.command()
async def calculate(ctx):
    await ctx.send("foo")

bot.run(TOKEN)

任何帮助将不胜感激.

推荐答案

PythonAnywhere 上的免费帐户不能使用 Discord websockets API,但您可以使用他们基于 HTTP 的 API.看看 论坛帖子,它解释了如何做到这一点.

Free accounts on PythonAnywhere can't use the Discord websockets API, but you can use their HTTP-based one. Take a look at the forum post that explains how to do that.

这篇关于ClientConnectorError:无法连接到主机 discordapp.com:443 ssl:默认 [连接呼叫失败('162.159.134.233',443)]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆