discord.py - 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)
解决方案
它不起作用,因为ctx.author
是None
,修复该启用intents.members
intents = discord.Intents.default()
intents.members = True
client = commands.Bot(..., intents=intents)
还要确保在开发人员门户中启用它们
推荐阅读
- php - 多个日期之间的小时总和
- math - 如何 ansible role1 输出 + role2 输出 = 打印结果
- javascript - 如何从异步等待函数而不是 Promise 返回布尔值
(打字稿|反应) - html - 从前端下载图像标签不起作用
- python - 尝试为 peewee 使用自定义 UUID mixin 不会覆盖基本 AutoField ID
- javascript - JS:不能对将被最小化或置于后台的页面使用异步剪贴板 API
- python - pyinstaller 不带包
- python - 直接从子进程输出解析 json 输出
- swift - 如何将对象数据类型上传到 Firestore 中的文档?
- c# - Visual Studio Form 上的错误“对象引用未设置为实例等”