Search code examples
pythondiscordpycharmdiscord.py

Redeclared 'bot' defined above without usage


The "bot" variable at the bottom is highlighted and says "Redeclared 'bot' defined above without usage". This is essentially all of my code up until that point. Please help!

from discord.ext import commands
from discord.ext import bot
from discord_slash import SlashCommand, SlashContext
from discord.utils import get
from discord_slash import cog_ext, SlashContext
from discord_slash.utils.manage_commands import create_choice, create_option
import pymongo
from pymongo import MongoClient
import random


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


bot = commands.Bot(command_prefix='!', case_insensitive=True, intents=intents)

Solution

  • This line of code imports a module named bot:

    from discord.ext import bot
    

    And then this line redefines the name bot, replacing the imported module name:

    bot = commands.Bot(command_prefix='!', case_insensitive=True, intents=intents)