Discord bot not working after conversion to nix

Hello!

I am not very good at all this, my discord bot is mainly frankenstein’d from others work… today I logged in to update one of the commands and the project was converted to nix and now will not work. Seems to be having issues on the first line where it says import discord

import discord
import os

client = discord.Client()

here is the error:

Traceback (most recent call last):
  File "main.py", line 1, in <module>
    import discord
ModuleNotFoundError: No module named 'discord'

as I said, I am not a developer, so i’m kind of at a loss for how to get it working again…

any help would be greatly appreciated!

1 Like

Hi, @MichaelBurke5!

Have you tried poetry add discord.py in the Shell tab? If that doesn’t work, use pip install -U discord.py instead.

Reason being, after migrating to Nix the discord.py package probably wasn’t installed, which is the reason Python didn’t know what the discord module was.

2 Likes

Will pip install discord work? @bobastley

1 Like

I was wondering that too, but the docs say to install with pip install -U discord.py.

I also read poetry installing doesn’t even work without additional configuration, but I put it in regardless because it’s usually better to install with poetry if possible on Replit.

2 Likes

just to circle back on this… I ended up having to install “idna” and then “discord.py” and then had to make a quick change to the client = bit…
from:

client = discord.Client()

to:

intents = discord.Intents.default()
intents.message_content = True

client = discord.Client(intents=intents)

not sure what all the intents part is… but the bot is now up and running.

Thank you for the assist!

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.