Module help discord

I can’t fix My code
The error is :

Traceback (most recent call last):

File "/home/runner/envyy-bot/main.py", line 3, in ‹module> from discord_slash import SlashCommand, SlashContext

ModuleNotFoundError: No module named 'discord_slash'

Line 3 :

from discord_slash import SlashCommand, SlashContext

Please help

Hello! The error message ModuleNotFoundError: No module named 'discord_slash' indicates that the required module discord_slash is not installed in your project environment. To resolve this issue, you need to install the discord_slash module using pip.

You can do this by running the following command in your Replit project terminal:

pip install discord-py-slash-command

Once you have successfully installed the module, you can import SlashCommand and SlashContext into your main.py file without encountering the import error.

Here’s an example of how your main.py file should look after adding the import statements:

import discord
from discord.ext import commands
from discord_slash import SlashCommand, SlashContext

# Your code here
# Make sure to use SlashCommand and SlashContext from discord_slash

# Example usage:
# bot = commands.Bot(command_prefix="!")
# slash = SlashCommand(bot, sync_commands=True)

# @bot.event
# async def on_ready():
#     print(f'Logged in as {bot.user}!')

# bot.run('YOUR_BOT_TOKEN')

Please try installing the module and updating your main.py file as shown above. Let me know if it works or if you encounter any further issues!

@Firepup650 I edited it because you said its not correct.

That’s not how pip works, and generally we recommend using poetry (Though that’s because for a long time pip caused issues, it shouldn’t anymore).

Either way:

pip install discord-py-slash-command
poetry add discord-py-slash-command
2 Likes

I’m new on Replit how do I run commands on the terminal :sweat_smile::sweat_smile:

Use the shell.

You can either use the “Ctrl+Shift+S” hotkey or you go to the Tools section at the left bottom of the screen and select the “Shell” option.

1 Like

I typed pip install discord-slash and it said Error could not find a version that satisfies the requirement discord-slash.
Poetry add discord-slash didn’t work , Expected = after a key at line 14 column 8

Search in the Packages tab first, try ‘discord-py-slash-command’

I did & it’s downloaded