ivy*_*ivy 2 python-3.x pythonanywhere discord discord.py
所以我尝试在 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)]
Run Code Online (Sandbox Code Playgroud)
这是我的代码片段:
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)
Run Code Online (Sandbox Code Playgroud)
任何帮助将不胜感激。
| 归档时间: |
|
| 查看次数: |
11252 次 |
| 最近记录: |