【发布时间】: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