我试图建立一个非常简单的机器人。基本上发送将由用户输入预定义的消息。但我只是测试了所有,并试图让我的头围绕它。
我们已经建立了一个Slack机器人,它的工作非常精彩。我似乎在寻找发送简单的预定义消息的最佳途径时遇到了问题。
我找到了一些教程,并附上下面的代码,以了解我应该做的事情。但它根本不是基于错误代码所说的连接。 '无法连接到主机discord app.com等
import discord
import asyncio
from discord.ext import commands
bot = commands.Bot(command_prefix='$', description='A bot that posts raffles.')
@bot.event
async def on_ready():
print('Logged in as')
print(bot.user.name)
print(bot.user.id)
print('------')
@bot.command()
async def raffle(ctx):
await ctx.send("Hello!")
bot.run('TOKEN')
如果你无法连接到主机,你很可能是IP禁止(或你的服务器),这可能意味着以前使用你的IP的人做了一些愚蠢的事情。要取消禁止,您应该发送电子邮件至[email protected]
另外,你试过在本地运行僵尸程序吗?