Search code examples
pythondiscordbotspycord

Discord bot message "application not responding"


I have a problem in my code.

this is my admin code :

import discord

class Admin(discord.Cog):
    
    def __init__(self, bot):
        self.bot = bot
        self._last_member = None

    @discord.command(name='clear', description='Permet de purger les messages du chat textuel.')
    async def clear(self, ctx:discord.ApplicationContext, amount):
        await ctx.channel.purge(limit=int(amount))

if __name__ == "__main__":
    import main

this is my main code :

# Import discord libs
import discord
from discord.ext import commands

# Import addon libs
import random
import asyncio

# Import extra libs
from libs import settings

# Import Cogs
import admin

client = commands.Bot(command_prefix=" ", help_command=None, intents=discord.Intents.default())

client.add_cog(admin.Admin(client))

@client.event
async def on_ready():
    print(f"logged in as {client.user}")
    print("Bot is ready!")
    await client.change_presence(status=discord.Status.online)

async def changepresence():
    await client.wait_until_ready()
    statuses = settings.BotStatus
    while not client.is_closed():
        status =  random.choice(statuses)
        await client.change_presence(activity=discord.Game(name=status))
        await asyncio.sleep(10)

client.loop.create_task(changepresence())
client.run(settings.TOKEN)

this is my console in Visual studio code :

enter image description here

when i use my command /clear amount: he result this error : but the command /clear amount: working perfectly :D

enter image description here

Can you help me to fix this please :D ?


Solution

  • You need to have the bot respond to the interaction: interaction.response.send_message("message")