pythonpython-3.xdiscorddiscord.pypycord

No module named 'discord.commands'


Traceback (most recent call last):
  File "D:\Redacted\path\main.py", line 8, in <module>
    from commands import setup_commands
  File "D:\Redacted\path\commands.py", line 4, in <module>
    from discord.commands import Option
ModuleNotFoundError: No module named 'discord.commands'

Tried uninstalling all discord related libraries then just install discord.py but im still getting the same issue


Solution

  • All in the documentation:

    In discord.py there are 2 types of commands:

    If you are looking for the new Slash commands, they are in discord.app_commands:

    from discord import app_commands
    

    If you are looking for the old commands, you need to import discord.ext.commands:

    from discord.ext import commands
    

    Please refer to the docs to see how to use each one, and good luck!