I have created some commands which can only be used by specific users. I do not want those commands to show in the drop-down list of the slash commands for everyone.
How to hide those commands?
I am using discord.py v2, hybrid commands
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()