Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/ant/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 3.x ClientConnectorError:无法连接到主机discordapp.com:443 ssl:默认[连接调用失败(';162.159.134.233';443)]_Python 3.x_Discord_Discord.py_Pythonanywhere - Fatal编程技术网

Python 3.x ClientConnectorError:无法连接到主机discordapp.com:443 ssl:默认[连接调用失败(';162.159.134.233';443)]

Python 3.x ClientConnectorError:无法连接到主机discordapp.com:443 ssl:默认[连接调用失败(';162.159.134.233';443)],python-3.x,discord,discord.py,pythonanywhere,Python 3.x,Discord,Discord.py,Pythonanywhere,所以我试着在Discord中制作一个机器人,我试着在Gitpod上运行我的Discord机器人,它能够运行,但当我试着在pythonanywhere.com上运行它时,我得到了以下错误: aiohttp.client_exceptions.ClientConnectorError: Cannot connect to host discordapp.com:443 ssl:default [Connect call failed ('162.159.134.233', 443)] 以下是我的代

所以我试着在Discord中制作一个机器人,我试着在Gitpod上运行我的Discord机器人,它能够运行,但当我试着在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)

任何帮助都将不胜感激。

Pythonywhere上的免费帐户不能使用Discord websockets API,但您可以使用他们基于HTTP的API。请看一看说明如何做到这一点的。Pythonywhere上的免费帐户不能使用Discord websockets API,但可以使用基于HTTP的API。看一看说明如何做到这一点的示例