我不确定为什么这些命令不起作用。每当我在我的 Discord 服务器中输入 !hello 时,机器人都不会响应。
import discord
from discord.ext import commands
import os
my_secret = os.environ['Token']
client = commands.Bot(command_prefix='!')
@client.command(pass_context=True)
async def hello(ctx):
await ctx.send("Hello")
client.run(my_secret)
答案 0 :(得分:0)
这应该有效 我刚刚测试过,效果很好 你安装了 Discord 吗?你的令牌写对了吗?
您也应该将此代码放入您的代码中,以便您查看机器人何时准备就绪
@client.event
async def on_ready():
print(" ")
print("Bot started! | Informations:")
print(f"- Name: {client.user.name}")
print(f"- Bot-ID: {client.user.id}")
print(f"- Server using {client.user.name}:",
len(client.guilds))