'SlashCommand' object is not callable
Summary
This issue is about a warning that happens when trying to use slash commands using the @bot.slash_command() decorator.
Reproduction Steps
Trying to use any kind of slash command. This issue also happens with the code example from the readme of the github page.
Minimal Reproducible Code
@bot.slash_command()
async def hello(ctx, name: str = None):
name = name or ctx.author.name
await ctx.send(f"Hello {name}!")
### Expected Results
No warnings given for the slash command decorator.
### Actual Results

### Intents
intents = discord.Intents.all()
### System Information
- Python v3.9.1-final
- pycord v2.0.0-alpha
- pycord pkg_resources: v2.0.0a3785+g16dcf2c6
- aiohttp v3.7.4.post0
- system info: Windows 10 10.0.19041
### Checklist
- [X] I have searched the open issues for duplicates.
- [X] I have shown the entire traceback, if possible.
- [X] I have removed my token from display, if visible.
### Additional Context
_No response_
Unable to reproduce. Could you please ask this question in a help channel in the Pycord server https://discord.gg/WCVGK4p7 and ping me (Zeffo#0393)?
Unable to reproduce. What did you define your bot variable as? Can you also show your imports, please?
Imports:
import discord
from discord.ext import commands, tasks
from database_managers.CaseManager import CaseManager
from database_managers.LawyerManager import LawyerManager
from database_managers.JudgeManager import JudgeManager
from database_managers.ReminderManager import ReminderManager
from web_handlers.MainForumScraper import MainForumScraper
from web_handlers.MainForumRegistryEditor import MainForumRegistryEditor
from config import bot_token, main_forum_name, main_forum_pass, guild_id
from Views.TakeCase import TakeCase
from Views.ReloadCases import ReloadCases
import re
from datetime import datetime
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt
Bot definition:
class Bot(commands.Bot):
def __init__(self):
super().__init__(command_prefix=commands.when_mentioned_or('.'), intents=intents)
self.guild = None
def get_channel_on_guild(self, channel_name):
channel_guild = discord.utils.get(self.get_all_channels(), name=channel_name).guild
channel_id = discord.utils.get(self.get_all_channels(), name=channel_name).id
return channel_guild.get_channel(channel_id)
@staticmethod
async def on_ready():
print("Bot is up.")
# three_hour_refresh.start()
reminder_thread.start()
renewal_loop.start()
@BruceCodesGithub
I should also mention that I'm on the master branch.
yeah same. regardless of what kind of bot definition I use (discord.Bot and commands.Bot) I still get the warning that it's not callable, tho when ran it works
This is also an issue for user_command, message_command.
So I've been really trying to see what causes this issue exactly and after looking in the code a bit and trying to understand it, I came to the conclusion that this warning was caused by the return type hinting of slash_command in bot.py, as upon removal of the type hinting for the return type, the warning went away.
A fix for this issue can be found in pull request #125
This should have been fixed.