在disconfirm.py 2.4+中,您可以通过以下方式使斜线命令在DM和Group DM中可用:
-
允许使用以下命令将命令安装到用户配置文件中
@discord.app_commands.allowed_installs
装饰师,以及
-
允许在DM和GDM(后者被称为
private_channels
)使用
@discord.app_commands.allowed_contexts
装饰师
此示例允许在任何地方安装和使用命令:
@discord.app_commands.allowed_installs(guilds=True, users=True)
@discord.app_commands.allowed_contexts(guilds=True, dms=True, private_channels=True)
@bot.tree.command(name="ping")
async def ping(ctx):
@discord.app_commands.allowed_installs
@discord.app_commands.allowed_contexts