Reputation: 57
I need to purge 10 messages as default and clear all channel, if printed -чисти все
. It worked, but my bot now don't purge any message and I don't know what I can do for fix it. Help pls
cha=ctx.message.channel
author=ctx.message.author
if all=='все' or all=="всё":
amount=0
history=await cha.history(limit=9999999).flatten()
for i in history:
amount+=1
await ctx.channel.purge(limit=1000) # amount instead 1000```
Upvotes: 0
Views: 456
Reputation: 124
If you're purging 10 messages, Context has everything you need to purge the channel. You can get the channel using Context.channel
and use the purge()
method to purge messages in a TextChannel. Then you can use the limit
kwarg to set a limit.
If you're trying to nuke the entire channel, Context also allows you to easily get the channel to nuke by using Context.channel
. Get the position of the TextChannel to be deleted using the attribute position
, make a clone using the clone()
method of TextChannel and delete the original channel using delete()
. Then use TextChannel.edit()
with the position
kwarg to fix the channel list.
Upvotes: 0
Reputation: 51
Try doing this:
async def clear(self, ctx, amount=10): # the amount is 10
await ctx.channel.purge(limit=amount) # set the default clear limit to 10
Upvotes: 1