ClientConnectorError:无法连接到主机discordapp.com:443 ssl:默认[连接呼叫失败('162.159.134.233',443)]

时间:2020-04-15 13:15:32

标签: python-3.x discord discord.py pythonanywhere

因此,我尝试在Discord中制作一个bot,并尝试在Gitpod上运行discord bot,并且该bot能够运行,但是当我尝试在pythonanywhere.com上运行它时,出现此错误:

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)

任何帮助将不胜感激。

1 个答案:

答案 0 :(得分:2)

PythonAnywhere上的免费帐户无法使用Discord websockets API,但您可以使用其基于HTTP的帐户。看一下forum post,它说明了如何做到这一点。