Discord.py mesaj silme kodu hata veriyor

arda662

Kilopat
Katılım
7 Eylül 2019
Mesajlar
1.221
Makaleler
6
Çözümler
25
Yer
Mersin
Discord'dan bot yazıyordum mesaj silme kodu hata veriyor.
Ignoring exception in command sil:
Traceback (most recent call last):
File "C:\Users\Arda\AppData\Local\Programs\Python\Python37-32\lib\site-packages\discord\ext\commands\core.py", line 85, in wrapped
ret = await coro(*args, **kwargs)
File "C:\Users\Arda\Desktop\Bot btw\kurti\kurti.py", line 52, in sil
await ctx.channel.purge(limit=str(amount+1))
TypeError: can only concatenate str (not "int") to str

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "C:\Users\Arda\AppData\Local\Programs\Python\Python37-32\lib\site-packages\discord\ext\commands\bot.py", line 939, in invoke
await ctx.command.invoke(ctx)
File "C:\Users\Arda\AppData\Local\Programs\Python\Python37-32\lib\site-packages\discord\ext\commands\core.py", line 863, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "C:\Users\Arda\AppData\Local\Programs\Python\Python37-32\lib\site-packages\discord\ext\commands\core.py", line 94, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: can only concatenate str (not "int") to str

@client.command()
@commands.has_permissions(manage_messages=True)
async def sil(ctx, amount):
await ctx.channel.purge(limit=str(amount+1))
await ctx.send(f'**{amount}** tane mesaj uzaya yollandı 🚀', delete_after=5)

Neyi yanlış yapıyor olabilirim? Str yerine int de yazdım. str(int şeklinde de yazdım hiçbir şekilde olmadı.
 
Verdiğiniz hata koduna göre await ctx.channel.purge(limit=str(amount+1)) kodunuzda hata var gibi gözüküyor hocam. str() kullanmanızı gerektirecek bir durum yok kodda. Size kendi botumda kullandığım silme kodunu atayım:

[CODE lang="python" title="Silme komutu"] async def sil(self, ctx, number: int = 1):
log_channel = bot.get_channel(BOT_LOG_KANALI)
asilnum = int(number) + 1
await ctx.channel.purge(limit=asilnum)
await ctx.send(f"{str(asilnum-1)} mesaj silindi.", delete_after=5)[/CODE]

Bu kod benim botumda sorunsuz bir şekilde çalışıyor. Bu kodu denediğinizde olmazsa eğer hata kodunu yine atabilir misiniz?
 

Yeni konular

Geri
Yukarı