My Discord bot was working perfectly fine last week but now it’s throwing a bunch of errors after I tried to upgrade discord.py to support slash commands. I’m getting a 401 Unauthorized error that says “Improper token has been passed” but I haven’t changed my token at all.
Here’s my bot code:
import discord
from discord.ext import commands
from config import *
bot = commands.Bot(command_prefix=['?', '#', '~', '+', '%'])
@bot.event
async def on_ready():
print('Bot is online!')
print('==================')
@bot.event
async def greet(ctx):
await ctx.send('Hi there!')
@bot.event
async def on_member_join(member):
with open('welcome_image.jpg', 'rb') as f:
image = discord.File(f)
welcome_channel = bot.get_channel(123456789012345678)
await welcome_channel.send('Welcome to the server! Here is your starter pack!', file=image)
@bot.event
async def farewell(ctx):
await ctx.send('See you later!')
@bot.event
async def explode(ctx):
with open('boom.gif', 'rb') as f:
boom_gif = discord.File(f)
await ctx.send('KABOOM!!!', file=boom_gif)
bot.run(BOT_TOKEN)
The error traceback shows LoginFailure and HTTPException errors. I double checked my token in the config file and it looks correct. Should I reinstall discord.py or is there something else I’m missing? This is really confusing for someone new to Python like me.