My python based discord bot is not responding to any commands entered, and the initial method is not printing anything

Viewed 97

When I iniatiate my discord bot,the on_ready method does not work. The bot comes online,but none of the code in the method prints in the command line. Also,the info command fails to work. This is all code that worked previously with another bot that I wrote, so I'm unsure as to what is failing to work. The code is included below.

from discord.ext import commands
import discord


client = discord.Client()


TOKEN = "insert token here"
description = "Bot that does things"
bot = commands.Bot(command_prefix="$", description="testbot")


@bot.event
async def on_ready():
    print("Logged in as")
    print(bot.user.name)
    print(bot.user.id)
    print("-----------------")
    print("Developed by")
    print("me")


@bot.command()
async def info(ctx):
    embed = discord.Embed(
        title="Commands", description="Here are the commands:", color=0xFFFF00
    )
    embed.add_field(name="meme", value="gives you a  meme", inline=True)
    print("Cmd entered")


client.run(TOKEN)
1 Answers

This is likely because you have both client (a discord.Client instance) and bot (a discord.ext.commands.Bot instance) defined. If you remove client and change client.run() to bot.run(), the bot should work.

from discord.ext import commands
import discord


TOKEN = "insert token here"
description = "Bot that does things"
bot = commands.Bot(command_prefix="$", description="testbot")


@bot.event
async def on_ready():
    ...

@bot.command()
async def info(ctx):
    ...


bot.run(TOKEN)
Related