首页 > 解决方案 > Discord.py 回显命令

问题描述

所以我试图做一个 discord.py echo/say 命令,但没有响应或错误发生,如果你知道如何解决这个问题,请帮帮我!

import discord, os, keep_alive, asyncio, datetime, pytz, requests

from discord.ext import tasks, commands

client = commands.Bot(
  command_prefix=':',
  self_bot=True
)

async def on_ready():
    client.remove_command('help')
    await client.change_presence(status=discord.Status.online, activity=discord.Game("TEST"))



@client.command()
async def echo(ctx, *,args):
    if ctx.message.author.id in [782258096210051102]:
        await ctx.send(args)
        await ctx.message.delete()
    else:
        await ctx.send("Bot developers only :<")

keep_alive.keep_alive()
client.run(os.getenv("TOKEN"), bot=False)

标签: discord.py

解决方案


它不起作用,因为ctx.authorNone,修复该启用intents.members

intents = discord.Intents.default()
intents.members = True

client = commands.Bot(..., intents=intents)

还要确保在开发人员门户中启用它们

参考


推荐阅读