xXSkillexZ
xXSkillexZ

Reputation: 105

Bot not responding after running the purge command. discord.py

I've seen a lot of these problems and I'm currently running in the same issue. My bot is not responding to the "purge" command. I tried different methods but still it's not working. I printed twice in the beginning of the command and at the end of it and it seems the first one works fine but the second does not. So what's the matter?

    @commands.command()
    async def clear(self, ctx, *, limit=100):
        channel = ctx.message.author.discord.text_channel.name
        await channel.purge(limit = amount)

That's the code. It's also in a cog. Also I mentioned that I printed twice:

    @commands.command()
    async def clear(self, ctx, *, limit=100):
        print("x")
        channel = ctx.message.author.discord.text_channel.name
        await channel.purge(limit = amount)
        print("y")

Basically only x got printed when running the command. So the problem has to be await channel.purge(limit = amount. Anyone has any ideas? Any answers will be appreciated! Also I forgot to mention that there are no errors.

Upvotes: 0

Views: 179

Answers (2)

Kelo
Kelo

Reputation: 1893

There are two issues with your function. As RandomGuy's answer indicates, you require the limit = limit as you've declared your purge limit variable as limit not amount.

You are also trying to purge from a channel name, not a channel object. You need to change this line:

channel = ctx.message.author.discord.text_channel.name

to:

channel = ctx.channel

Upvotes: 3

RandomGuy
RandomGuy

Reputation: 206

The amount var is not defined you should be using limit

await channel.purge(limit = limit)

Upvotes: 1

Related Questions