我不知道怎么做,但我很久以前就已经开始工作了,但我不再有代码了,而且我什至不使用它是斜杠命令还是常规命令。
如您所见,这是我在我的 DMS 中使用机器人。现在我有一个新的机器人,我试图通过添加我的个人帐户的公会 ID 来做到这一点,但它给了我这个错误
discord.errors.Forbidden: 403 Forbidden (error code: 50001): Missing Access
这就是我的斜线命令的样子:
from discord.ext import commands
from discord_slash import SlashCommand, SlashContext
bot = commands.Bot(command_prefix='$', intents=Intents.all())
slash = SlashCommand(bot, sync_commands=True)
@slash.slash(name="test", guild_ids=[guild_id_of_server])
async def test(ctx: SlashContext):
...
这在我的服务器中完美地工作,我只是想让它在我的 dms 中工作。应该更改机器人的权限吗?
最佳答案
您添加了guild_ids=[guild_id_of_server]
,因此它将仅在服务器上工作
@slash.slash(name="test", guild_ids=[guild_id_of_server])
async def test(ctx: SlashContext):
只需将其删除即可完成!
@slash.slash(name="test")
async def test(ctx: SlashContext):
关于python - 是否可以在 dms 中使用斜杠命令来处理 discord py?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/71806440/