#Are you able to use interactions.slash_command & interactions.ext.prefixed_commands in one bot?

1 messages · Page 1 of 1 (latest)

fathom canopy
#

Hey i would like to add some secret Commands that can only used by my self to fix the Bot / reload extensions / print logs etc.
I dont want the command to appear in the /command section so i thought why shouldnt i use prefixed commands but this doesnt seem to work.

prime canopyBOT
#

Hey! Once your issue is solved, press the button below to close this thread!

glacial moss
#

yeah u can use both in the same bot

#

u might be forgetting to initialise the prefixed command ext in ur main bot file

#

Put this line: prefixed_commands.setup(bot, default_prefix='insert_prefix_here') before you start the bot in your main file

#

and then in ur ext:

from interactions.ext.prefixed_commands import prefixed_command, PrefixedContext

... your ext stuff

@prefixed_command("command_name")
    async def my_prefixed_command(self, ctx: PrefixedContext):
        # Do stuff here
summer nova
#

you could also use the default_member_permissions flag in @slash_command

#

Then the slash command will only show for the users with that permission

fathom canopy
fathom canopy
glacial moss
#
bot = Client(
        token = TOKEN,
        intents = Intents.DEFAULT | Intents.MESSAGE_CONTENT
        )```
whole plover
#

so that means that admins with all permissions WILL see it

#

if you want something only YOU can use, then a regular if condition is your best way

summer nova
#

Then your @slash_command under it

#

That command should only be visible by you after that point

whole plover
#

no it will be visible by everyone

#

but only execute if you use that command

summer nova
#

Oh really? 🤔

whole plover
#

or actually I have an idea

glacial moss
#

if u want to do a slash command only visible to you i think the only way would be to manually configure it in the integrations permissions menu

whole plover
#

you can set custom scopes to commands, so maybe set your "private" commands with a scope of a server that ONLY you have access to

whole plover
summer nova
#

that could work, but become very annoying after a while 😅

#

Imo* I’m not the one using it but

glacial moss
#

yeah true

summer nova
glacial moss
#

if ur gonna hide it manually no point is doing is owner too

#

wouldnt make a difference since nobody else could see it

whole plover
fathom canopy
#

is_owner check referes to the server owner right?

glacial moss
#

bot owner i believe

summer nova
fathom canopy
#

but where do i set the bot owner?

summer nova
whole plover
summer nova
glacial moss
whole plover
#

ie the one that has access to modifying the token, name of bot etc

glacial moss
#

oh its automatic?

fathom canopy
#

ohh so its set via the Token?

summer nova
fathom canopy
#

Makes sence.

whole plover
glacial moss
#

yeah i was doing it like that in my bot, guess i can remove it then

whole plover
fathom canopy
#

yea its nice for working in a team

glacial moss
#

i can see how it would be handy, sadly im working alone 😔

summer nova
#

You may be able to setup a team and it pull those users as owners? Idk maybe wrong

fathom canopy
#

it tells me that there was a KeyError: "unload"

whole plover
#

give a better traceback pls

summer nova
#

^

#

I would also not use async def send()

#

I would just changed that to unload()

fathom canopy
#

Task exception was never retrieved
future: <Task finished name='Task-114' coro=<Client._dispatch_interaction() done, defined at C:\Users\milan\PycharmProjects\SMP_Stuff\venv\lib\site-packages\interactions\client\client.py:1763> exception=KeyError('unload')>
Traceback (most recent call last):
File "C:\Users\milan\PycharmProjects\SMP_Stuff\venv\lib\site-packages\interactions\client\client.py", line 1788, in _dispatch_interaction
if ctx.command:
File "C:\Users\milan\PycharmProjects\SMP_Stuff\venv\lib\site-packages\interactions\models\internal\context.py", line 311, in command
return self.client._interaction_lookup[self._command_name]
KeyError: 'unload'

whole plover
#

try to restart your bot

fathom canopy
#

tried several times

#

still the same

glacial moss
#

try change the name and see if it still happens

fathom canopy
whole plover
#

put the is_owner under the slash command

fathom canopy
#

i now get a runtime error since "is owner" is not awaited

summer nova
#

Did you import is_owner? 😅 I know that sounds stupid but

fathom canopy
#

yea xD

brave wedge
#

Isn't it @check(is_owner())?

fathom canopy
#

any idea what this is: ```interactions.client.errors.CommandCheckFailure: (SlashCommand(max_concurrency=Missing, pre_run_callback=None, scopes=[0], auto_defer=Missing), <function is_owner.<locals>.check at 0x0000015202867250>, <interactions.models.internal.context.SlashContext object at 0x00000152028A0A30>)

summer nova
brave wedge
#

Huh

#

I just use the API docs mostly, not the guides

summer nova
brave wedge
#

Should probably be mentioned to the devs then.

fathom canopy
fathom canopy
# summer nova

it didnt work with @is_owner() but with the @muted moat(is_owner())

whole plover
summer nova
summer nova
whole plover
summer nova
#

I just noticed that

muted moat