我有一个通过GitHub使用Heroku托管的机器人。它在线,但是所有命令都不起作用。
我不知道该怎么做,我对这种机器人托管的东西还没有很丰富的经验。 dyno在线并且令牌在配置变量中。以下是requirements.txt和bot.py。
import discord
from discord.ext import commands
from discord.ext.commands import Bot
from discord.ext.commands import has_any_role
from discord.ext.commands import CheckFailure
import asyncio
import random
import requests
import os
client = commands.Bot(command_prefix="-")
client.remove_command("help")
@client.command(pass_context=True)
@has_any_role("Postal Manager", "Board of Directors", "Chief Executive Officer")
async def giverole(ctx, member: discord.Member, *, role: discord.Role):
user = ctx.message.author
await client.add_roles(member, role)
await client.say(f"The role '{role}' has been given to {member.mention} by {user.mention}.")
@giverole.error
async def giverole_error(error, ctx):
if isinstance(error, CheckFailure):
await client.say("Error: Do not have sufficient roles for command.")
@client.command(pass_context=True)
@has_any_role("Postal Manager", "Board of Directors", "Chief Executive Officer")
async def removerole(ctx, member: discord.Member, *, role: discord.Role):
user = ctx.message.author
await client.remove_roles(member, role)
await client.say(f"The role '{role}' has been removed from {member.mention} by {user.mention}.")
@removerole.error
async def removerole_error(error,ctx):
if isinstance(error, CheckFailure):
await client.say("Error: Do not have sufficient roles for command.")
@client.command(pass_context=True)
async def allies(ctx):
author = ctx.message.author
await client.say(f"__**Allies**__ {author.mention} \n \n Our current allies are: \n \n• **DHL** \n \n DHL is a company that ensures a safe and reliable delivery service. \n\n **Contract:** https://docs.google.com/document/d/1M7y2dpwnItQ2545DlgWEBH9qJRT_0fN3ePGKFCA4Guw/edit?usp=drivesdk \n \n **Discord:** https://discord.gg/yTEVtPQ")
@client.event
async def on_ready():
print("Bot is ready!")
bot_token:client.run(str(os.environ.get('BOT_TOKEN')))
discord
requests
asyncio
希望,当我进行部署时,该机器人将保持在线状态,并且命令将起作用。非常感谢。