【发布时间】:2021-03-19 23:41:51
【问题描述】:
我想创建一个仅在用户 DMing 他们的命令时才有效的命令。我怎么做?我正在使用 discord.py 1.5.1,而且我对 discord.py 还很陌生。 到目前为止,这是我的代码:
from discord.ext import commands, tasks
import discord
intents = discord.Intents.all
bot = commands.Bot(command_prefix='$', description='- shows this message', intents=intents)
---- snip ----
@commands.command(brief='a DM command')
async def dm_command(ctx):
# do stuff here
bot.run('TOKEN')
当我尝试 DMing 命令时,机器人不会接收我发送的 DM。我应该在 on_message() 中指定命令吗?
【问题讨论】:
-
"有什么办法吗?"我确定有。 (可以用简单的“是”或“否”回答的问题通常不适合 Stack Overflow 的问答格式。编辑您的问题以分享更多相关细节,至少包括到目前为止您在尝试解决手头的问题,并详细说明在这些尝试中具体遇到的问题。堆栈溢出不会为您编写代码 你。另见:How to Ask)
-
对不起,我已经更新了问题。