【问题标题】:Commands for discord bot not working (Python)不和谐机器人的命令不起作用(Python)
【发布时间】:2021-10-05 22:39:00
【问题描述】:

我不确定为什么这些命令不起作用。每当我在我的不和谐服务器中输入 !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)

【问题讨论】:

    标签: python discord discord.py


    【解决方案1】:

    这应该工作 我刚刚测试了它,它工作得很好 你安装了 Discord 吗?你的 Token 写对了吗?

    您还应该将此代码放入您的代码中,以便查看 Bot 何时准备就绪

    @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))
    

    【讨论】:

    • 是的,我有我的令牌和所有启动我的机器人和东西的东西。我正在尝试向我的机器人添加命令,当我输入触发词时,我的机器人在聊天中没有发送任何内容。
    • 您的 Bot 是否有权查看聊天中的消息?
    猜你喜欢
    • 2018-11-10
    • 2020-09-25
    • 2021-02-25
    • 2023-03-20
    • 2018-07-21
    • 2021-10-21
    • 2022-01-15
    • 2021-06-17
    • 2021-07-26
    相关资源
    最近更新 更多