Hey everyone! I’m trying to create a Discord bot using Python but I’m running into some problems. My code editor is showing 4 errors and I can’t figure out why. I’ve got discord.py installed and I’m using Python 3.5.
Here are the errors I’m seeing:
No name 'exe' in module 'discord'
Undefined variable 'message'
Unable to import 'discord.exe.commands'
Undefined variable 'message'
Does anyone know what might be causing these? Here’s a simplified version of my code:
import discord
from discord.core.bot import BotClient
from discord.ext import tasks
bot = BotClient(prefix='!')
@bot.event
async def on_startup():
print('Bot is now online')
@bot.event
async def on_chat(text):
if text.content == 'snack':
await text.channel.send('🍿')
bot.start('YOUR_TOKEN_HERE')
Any help would be awesome! Thanks!
I’ve been down this road before, mate. Your issues are likely due to outdated code snippets and mismatched library versions. First off, ditch the ‘discord.core.bot’ import - it’s not a thing anymore. You want ‘discord.ext.commands’ instead. Replace ‘BotClient’ with ‘commands.Bot’. Also, ‘on_startup’ isn’t an event - use ‘on_ready’. And ‘on_chat’? That’s ‘on_message’ now.
Here’s a pro tip: always check the official discord.py documentation when you’re stuck. It’s a lifesaver. And consider upgrading your Python version - 3.5 is ancient history in bot development terms.
One last thing: triple-check your indentation. I’ve lost count of how many times a sneaky indent error has driven me up the wall. Keep at it, you’ll get there!
I’ve encountered similar issues when developing a Python-based Discord bot. It seems that some discrepancies in your code stem from outdated module references and event names. For example, importing from discord.core.bot is incorrect; you should import from discord.ext.commands and use commands.Bot instead. In addition, the event on_startup does not exist and should be replaced with on_ready, while on_chat should be adjusted to on_message. Upgrading your Python version and using a discord.py version that aligns with current standards could also help resolve these errors.
hey hiker, looks like ur using some old discord.py stuff. try importing from discord.ext.commands instead and use Bot instead of BotClient. also, change on_startup to on_ready and on_chat to on_message. that shud fix most of ur issues. good luck with ur bot!