【问题标题】:ClientConnectorError: Cannot connect to host discordapp.com:443 ssl:default [Connect call failed ('162.159.134.233', 443)]ClientConnectorError:无法连接到主机 discordapp.com:443 ssl:默认 [连接调用失败('162.159.134.233',443)]
【发布时间】:2020-07-28 11:31:03
【问题描述】:

所以我尝试在 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)]

这是我的代码的 sn-p:

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)

任何帮助将不胜感激。

【问题讨论】:

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


    【解决方案1】:

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

    【讨论】:

      猜你喜欢
      • 2020-11-30
      • 2020-09-07
      • 2020-04-26
      • 2016-11-25
      • 2015-06-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多