Skip to content

Last slash command registered is duplicated with no id in bot._application_commands #873

@krittick

Description

@krittick

Summary

When multiple slash commands are registered, the last one is registered again but without an id in bot._application_commands. It's likely that this will have cascading effects elsewhere, but so far was only noticed during testing for #838.

Reproduction Steps

Register more than one slash command and retrieve bot._application_commands

Minimal Reproducible Code

from discord.ext import commands
import discord
intents = discord.Intents.all()


bot = commands.Bot(command_prefix=[">"], intents=intents, owner_ids=[...])


@bot.slash_command(name="id_test", guild_ids=[...])
async def id_test(ctx):
    await ctx.respond("Test for id issue")
    await ctx.respond(bot._application_commands)


@bot.slash_command(name="id_test2", guild_ids=[...])
async def id_test2(ctx):
    await ctx.respond("Test 2 for id issue")
    await ctx.respond(bot._application_commands)

bot.run("token here")

Expected Results

Slash commands should not be added again with an empty ID once registered.

Actual Results

The following shows for _application_commands: (issue in bold)

{None: <discord.commands.SlashCommand name=id_test2>, '936482856040017940': <discord.commands.SlashCommand name=id_test>, '936482973384073356': <discord.commands.SlashCommand name=id_test2>}

Intents

All

System Information

- Python v3.10.0-final
- py-cord v2.0.0-beta
    - py-cord pkg_resources: v2.0.0b4872+g16661e72
- aiohttp v3.8.1
- system info: Windows 10 10.0.19043

Checklist

  • I have searched the open issues for duplicates.
  • I have shown the entire traceback, if possible.
  • I have removed my token from display, if visible.

Additional Context

This might get fixed with #759 but I'm logging the issue to keep it on our radar to test with those changes either way.

Metadata

Metadata

Assignees

Labels

unconfirmed bugA bug report that needs triaging

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions