#slash command options not working

1 messages · Page 1 of 1 (latest)

frigid ferry
#

hi, I recently started making a new bot after coming from V3 version of this library. I've created a test command with command options, but even though the command is showing up, the options aren't. This is my Code:

bot = Client(intents=Intents.DEFAULT, token=TOKEN)


@listen()
async def on_startup():
    print("bot is running")


@slash_command(name="channel_ban",
               description="excludes a member from a channel",
               options=[
                   SlashCommandOption(
                       name="channel",
                       description="the channel that the user should no longer be able to access",
                       required=True,
                       type=OptionType.CHANNEL
                   ), SlashCommandOption(
                       name="member",
                       description="the member who should no longer be able to access the channel",
                       required=True,
                       type=OptionType.USER
                   )
               ],
               scopes=[
                   806555455710691409
               ])
async def channel_ban(ctx: SlashContext, channel: GuildChannel, member: Member):
    print(channel)
    print(member)


bot.start()

The error Im getting makes sense to me, since I haven't been able to pass any arguments via discord, of course they are missing:

TypeError: channel_ban() missing 2 required positional arguments: 'channel' and 'member'

any ideas on why this is happening?

latent pathBOT
#

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

frigid ferry
#

this is what shows up:

opal reef
#

why not using @slash_options decorator?

#
@slash_command("channel_ban", description="excludes a member from a channel")
@slash_option("channel", "the channel that the user should no longer be able to access", OptionType.CHANNEL, required=True)
@slash_option("user", "the member who should no longer be able to access the channel", OptionType.USER, required=True)
async def channel_ban(ctx: SlashContext, channel: GuildChannel, member: Member):
    print(channel)
    print(member)
frigid ferry
glad yarrow
frigid ferry
glad yarrow
#

interminal

frigid ferry
#

that's weird

#

there are no logs in my terminal

glad yarrow
#

can you send the code youre running?

#

there should be a lot of stuff bursting from terminal unless you saved logs to othee places

frigid ferry
#
import logging
from interactions import Client, Intents


bot = Client(intents=Intents.DEFAULT,
             token=TOKEN,
             logging_level=logging.DEBUG)
#

this is what Im currently running

#

and this is what Im getting

frigid ferry
#
import logging

import interactions
from interactions import Client, Intents, listen, slash_command, SlashContext, Member, GuildChannel, SlashCommandOption, \
    OptionType, slash_option


bot = Client(intents=Intents.DEFAULT,
             token=TOKEN,
             logging_level=logging.DEBUG)


@listen()
async def on_startup():
    print("bot is running")


@slash_command(name="channel_ban",
               description="excludes a member from a channel",
               options=[
                   SlashCommandOption(
                       name="channel",
                       description="the channel that the user should no longer be able to access",
                       required=True,
                       type=OptionType.CHANNEL
                   ), SlashCommandOption(
                       name="member",
                       description="the member who should no longer be able to access the channel",
                       required=True,
                       type=OptionType.USER
                   )
               ],
               scopes=[
                   806555455710691409
               ])
async def channel_ban(ctx: SlashContext, channel: GuildChannel, member: Member):
    print(channel)
    print(member)


bot.start()
frigid ferry
#

Uhm I don't know why, but after coming back to the project, I have one command working like intended, but the other one with broken options is still there

#

any ideas on how to remove the broken one?

uncut inlet
#

There's an option to remove unused commands in the interactions.Client class

#

delete_unused_application_cmds

#

Just remember to remove it again after you're done as it delays the bot start by a bit

frigid ferry
#

thank you, this worked! Sorry for the late response though...