Hi, I'm trying to make an autocomplete function to let a user choose a channel by its name and return the ids of the channel (it's fetched in a database)
async def get_game_channel_associations(
self, ctx: discord.AutocompleteContext
) -> list[discord.OptionChoice]:
"""
Get the game channels names with there ids associated from the database.
Returns:
A dictionary with the game channels names and their ids.
"""
async with self.bot.database.get_session() as session:
game_categories: list[GameCategory] = await GameCategoryManager.get_all(session)
if not game_categories:
return [discord.OptionChoice(
name="No game categories found", value=-1
)]
return [
discord.OptionChoice(
name=game_category.name,
value=str(game_category.id)
)
for game_category in game_categories
]
but when I call the funciton in a slash_command I get this :
Task exception was never retrieved
future: <Task finished name='Task-15' coro=<ApplicationCommandMixin.on_application_command_auto_complete.<locals>.callback() done, defined at /app/.venv/lib/python3.13/site-packages/discord/bot.py:876> exception=HTTPException('400 Bad Request (error code: 50035): Invalid Form Body\nIn data.choices.0.value: int53 value should be less than or equal to 9007199254740991.')>
Traceback (most recent call last):
...
In data.choices.0.value: int53 value should be less than or equal to 9007199254740991.