Discord bot select menu callback function throwing AttributeError

I’m working on a Discord bot that uses a select menu to display help commands. The bot should show all available commands when users pick an option from the dropdown.

import os
import discord
from discord.ui import Select, View
from discord.ext import commands
import json

def get_config(path):
    with open(path, 'r') as f:
        return json.load(f)

config_file = os.path.join(os.path.dirname(__file__), '..', 'settings', 'bot_config.json')
bot_config = get_config(config_file)
bot_prefix = bot_config['BOT_PREFIX']

class CommandsMenu(View):
    @discord.ui.select(
        placeholder="Select what you need assistance with",
        min_values=1,
        max_values=1,
        options=[
            discord.SelectOption(
                label='Available Commands', 
                description='Display all bot commands and their usage.', 
                emoji='📋', 
                value=1
            )
        ]
    )
    async def menu_callback(self, selection, interaction_obj):
        selection.disabled = True
        
        if selection.value[0] == '1':
            bot_commands = self.bot.commands
            
            help_embed = discord.Embed(
                title='Available Bot Commands',
                color=discord.Color.green()
            )
            
            for cmd in bot_commands:
                cmd_variants = [f'{bot_prefix}{cmd.name}'] + [f'!{alt}' for alt in cmd.aliases]
                alias_list = ', '.join(cmd_variants[1:]) if len(cmd_variants) > 1 else 'No aliases'
                
                help_embed.add_field(
                    name=cmd_variants[0],
                    value=f'Info: {cmd.description}\nAliases: {alias_list}',
                    inline=False
                )
            
            await interaction_obj.response.edit_message(embed=help_embed)

class BotCommands(commands.Cog):
    def __init__(self, client):
        self.bot = client
    
    @commands.command(
        name='help',
        aliases=['assistance', 'commands'],
        description='Shows information about bot functionality.'
    )
    async def show_help(self, context):
        help_menu = CommandsMenu()
        await context.reply(view=help_menu)

async def setup(client):
    await client.add_cog(BotCommands(client))

I keep getting this error when someone clicks the dropdown:

AttributeError: 'Interaction' object has no attribute 'disabled'
Traceback (most recent call last):
  File "discord/ui/view.py", line 427, in _scheduled_task
    await item.callback(interaction)
  File "bot_commands.py", line 28, in menu_callback
    selection.disabled = True

The error happens in the callback function where I try to disable the select menu. I’ve looked through Discord.py docs but can’t figure out what I’m doing wrong. Any ideas on how to fix this?

Others covered the main issues, but here’s a different approach that’ll save you headaches.

Skip debugging Discord bot callbacks and passing bot instances around. Just automate the whole help system. I built something similar - the help menu updates itself whenever I add new commands.

Set up a workflow that watches your command files for changes, then auto-generates updated help embeds and pushes them to your Discord channels. No more manual callback debugging or parameter headaches.

You can automate the entire bot deployment too. Push code changes and it automatically restarts the bot, updates command registrations, and sends status notifications to your Discord server.

This kills the AttributeError issues completely since you’re not dealing with complex UI callbacks. The help system becomes a simple automated message that stays synced with your actual commands.

I’ve used this pattern for several Discord bots and it’s way more reliable than debugging UI component lifecycles. Plus you get automatic documentation updates.

I hit this exact same bug recently and there’s one thing everyone missed. Your comparison logic is broken - you’re doing if selection.value[0] == '1': but SelectOption values in Discord.py keep whatever type you originally set. Since you used value=1 as an integer, not a string, that condition never triggers.

Fix the callback parameters like the others said, then change your comparison to if select.values[0] == 1 (no quotes). The values list has the actual integer from your SelectOption constructor. I wasted hours on this same mistake because the string comparison failed silently and my embed never appeared.

Yeah, you’re passing the bot reference wrong. Fix your show_help method to pass self.bot to CommandsMenu like help_menu = CommandsMenu(self.bot) and add def __init__(self, bot): self.bot = bot to your view class. Without that, self.bot.commands won’t work even after you fix the callback parameters.

Your callback function signature is wrong. You’ve got async def menu_callback(self, selection, interaction_obj) but it should be async def menu_callback(self, interaction, select). Discord.py passes the interaction first, then the select component. Also, fix your condition check - use select.values[0] instead of selection.value[0] since values is a list. And you need to pass the bot instance to your CommandsMenu class since you’re trying to access self.bot.commands but the View doesn’t have it. Just add an __init__ method that takes the bot parameter and stores it as an instance variable.

Your callback function parameters are backwards. Switch them - interaction comes first, then select: async def menu_callback(self, interaction, select):. Use select.disabled = True instead of what you have now. Also, you’re using selection.value[0] but it should be select.values[0] to get the selected value. The interaction object doesn’t have a disabled attribute, that’s why you’re getting the AttributeError. I hit this same issue when I started with Discord.py select menus - the docs make the parameter order confusing.