Forum Archive

Discord.py problems

0_0

Hi, I originally downloaded pythonista to develop a discord bot. But, everytime I do the following code I get errors:

import discord
from discord.ext.commands import Bot
from discord.ext import commands

I get the following errors: no module named “discord.ext”; “discord is not a package.

dgelessus

Is the file with your code called discord.py perhaps? If so, you need to rename it - otherwise when you say import discord, it will import your own script instead of the discord module.

Also just FYI, it's not possible to have a Python script run while Pythonista is in the background - iOS does not allow apps to run in the background for a long time. I don't know anything about writing Discord bots, but I assume that you have to keep your script running in order for the bot to work. So if you want your bot to always run, without having to start it manually first, you're probably better off running it on a regular computer instead of a mobile device.

0_0

@dgelessus Yes, I have renamed the file to my_bot.py from discord.py, I was unaware. I now have a new error:

No module named ctypes.macholib
JonB

Google is your friend:
https://github.com/omz/Pythonista-Issues/issues/311