thottivelli
thottivelli

Reputation: 81

Slash commands produce "interaction failed" when invoked in chat?

I am using the discord-py-slash-command library and have setup my commands. However when I type my command in the chat I get interaction failed each time. I have given my bot the correct scope and reinvited it to the server several times. Can someone take a look at my code an tell me what is going on? I have followed several tutorials with no luck.

TOKEN = open("./token.txt", "r").readline()

bot = commands.Bot(command_prefix='-', intents=discord.Intents.all())
slash = SlashCommand(bot, sync_commands=True)


@bot.event
async def on_ready():
    print(f'{bot.user.name} has connected to the Discord!')


@slash.slash(name="test", description='Test slash command activated', guild_ids= 
[928451150515150890])
async def test(ctx: SlashContext):
    embed = discord.Embed(title="Embed Test")
    await ctx.send(embed=embed)

Upvotes: 0

Views: 410

Answers (2)

thottivelli
thottivelli

Reputation: 81

i switched over to the nextcord library for slash commands and the behavior is working as expected... I will consider this closed

Upvotes: 0

stryker0808
stryker0808

Reputation: 43

Edit: I am editing my answer because at the time I was not sure what library you were using.

Your code works just fine, however, If you are going to use intents=discord.Intents.all()

you need to be sure to enable presence as well as server members intents in the developer console of the bot.

If you do not need to use intents for your application, disable them and set it to intents=discord.Intents.default()

Upvotes: 1

Related Questions