【发布时间】:2022-07-10 22:16:31
【问题描述】:
我正在尝试使一些斜线命令仅对机器人所有者可见,例如加载/卸载我的 cog 的命令等。
以下是我的代码:
@client.slash_command(name="load", description="Cog Loader",guild_ids=[937755377901133896])
@commands.is_owner()
async def load(interaction: Interaction, cog: str = nextcord.SlashOption(name="cogs", description="Name of the Cog.")):
try:
await client.load_extension(cog)
await interaction.response.send_message(f"Loaded: {cog}")
except Exception as e:
await interaction.response.send_message(f"Error: {e}")
@client.slash_command(name="unload", description="Cog Unloader",guild_ids=[937755377901133896])
@commands.is_owner()
async def unload(interaction: Interaction, cog: str = nextcord.SlashOption(name="cogs", description="Name of the Cog.")):
try:
await client.unload_extension(cog)
await interaction.response.send_message(f"Unloaded: {cog}")
except Exception as e:
await interaction.response.send_message(f"Error: {e}")
【问题讨论】:
-
不,你不能这样做。您只能在 guilds_ids 中将您的 slash cmd 指定为您想要的服务器。您可以使用
if interaction.user == youruserid来阻止其他人使用此命令,但它仍然对所有人可见。希望这可以帮助你。 -
猜猜我将不得不为这些特定命令建立一个私人服务器,Thnx 的评论:)
标签: python discord bots nextcord