#Are you able to use interactions.slash_command & interactions.ext.prefixed_commands in one bot?
1 messages · Page 1 of 1 (latest)
Hey! Once your issue is solved, press the button below to close this thread!
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
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
can i make it that it only shows to users with specific IDs?
so i tried it and i now get this error: "Prefixed commands will not work since the required intent is not set -> Requires: <Intents.MESSAGE_CONTENT: 32768> or usage of the default mention prefix as the prefix"
you need to add the intent to your bot in the discord application site and when u create ur bot instance also
bot = Client(
token = TOKEN,
intents = Intents.DEFAULT | Intents.MESSAGE_CONTENT
)```
no, it only works with server permissions
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
you could use
from interactions import is_owner
@is_owner()
Then your @slash_command under it
That command should only be visible by you after that point
Oh really? 🤔
^yes unfortunately
or actually I have an idea
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
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
true but not very scalable if you have plenty of servers
that could work, but become very annoying after a while 😅
Imo* I’m not the one using it but
yeah true
I mean you could always use the is_owner check and hide the command via your interactions page through server settings right?
if ur gonna hide it manually no point is doing is owner too
wouldnt make a difference since nobody else could see it
Yes you can, but that will only work if you have a single server
is_owner check referes to the server owner right?
bot owner i believe
Bot owner
but where do i set the bot owner?
Yeah that’s true
well, that's simply the owner of the bot lol
If I’m not mistaken, it’s checked based on the user who created the bot through DDP
when u create the bot instance in ur main file
ie the one that has access to modifying the token, name of bot etc
oh its automatic?
(Discord Developer Portal)
ohh so its set via the Token?
Correct
Makes sence.
yes, but actually you can also add "fake" owners when instantiating it.
client = i.Client(..., owner_ids=[...])
yeah i was doing it like that in my bot, guess i can remove it then
it's a cool feature if you want the bot to behave as if it had multiple owners, since I believe Discord only allows one owner natively
yea its nice for working in a team
i can see how it would be handy, sadly im working alone 😔
You may be able to setup a team and it pull those users as owners? Idk maybe wrong
Uhm i tried with is_owner() with the following code:
@slash_command(name="unload", description="OP-Command")
@slash_option(name="password", description="--", required=True, opt_type=OptionType.STRING)
async def send(ctx: SlashContext, password: str):
await ctx.send(f"Input {password}")```
it tells me that there was a KeyError: "unload"
give a better traceback pls
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'
try to restart your bot
try change the name and see if it still happens
so apperently it has something todo with the @is_owner
put the is_owner under the slash command
i now get a runtime error since "is owner" is not awaited
Did you import is_owner? 😅 I know that sounds stupid but
yea xD
Isn't it @check(is_owner())?
yea that was it.
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>)
No, according to the docs, it’s just @is_owner()
Is that the full error?
Well, me too. Until I saw this lol
Should probably be mentioned to the devs then.
yes
it didnt work with @is_owner() but with the @muted moat(is_owner())
poor guy got again pinged 😭
Oh I’m okay 😅 just at work
That’s interesting. Works for me ¯_(ツ)_/¯
I was talking about the other guy! @ Check
I really should change my name