【发布时间】:2022-08-20 23:30:03
【问题描述】:
我创建了一些只能由特定用户使用的命令。我不希望这些命令显示在每个人的斜杠命令的下拉列表中。
如何隐藏这些命令?
我正在使用 discord.py v2,混合命令
import discord
from discord import app_commands
from discord.ext import commands
from utils.constants import owner_list
discord.http._set_api_version(9)
class owner_commands(commands.Cog):
def __init__(self, bot):
self.bot = bot
@commands.hybrid_command(name=\'sc\', with_app_command=True)
async def sc(self, ctx: commands.Context):
# SENDS A MESSAGE TO THE CHANNEL USING THE CONTEXT OBJECT.
if(str(ctx.message.author.id) in owner_list):
embed = discord.Embed(title=str(len(self.bot.guilds))+\" servers!\", color=0xCC0066)
await ctx.send(embed=embed, ephemeral=True)
else:
await ctx.send(\"Command is not available\")
async def setup(bot: commands.Bot) -> None:
await bot.add_cog(owner_commands(bot))
await bot.tree.sync()
-
你的密码是什么?
-
不,这不对。您只能同步公会或全局。
-
我不认为这是可能的,你能做的最好的就是实施权限检查,然后如果某些条件不意味着就拒绝执行它。
-
有可能,你只需要做一些恶作剧就可以让 discord.py 随命令一起发送一些额外的数据。 discord.com/developers/docs/interactions/…。我稍后会回来提供有效的答案
-
我找到了一种通过应用程序命令使用权限的方法。但是 discord 本身似乎并没有实现它们。如果您愿意,我可以发布使用 discord.py 权限的方法作为答案,但这并不是真正的方法。
标签: python discord discord.py