[英]Discord.py purge command not purging (selfbot)
所以我一直在尝试为 Discord 制作一个自我机器人,但我的代码没有成功,我有点想了解哪里出了问题。 我正在尝试编写清除命令并发生以下情况:
main.py 代码:
import discord
import asyncio
from discord.ext import commands
# Importing Cogs
from cogs.purge import purge
bot = commands.Bot(command_prefix= ".")
@bot.event
async def on_ready():
print("nani?! 👀")
await bot.change_presence(activity=discord.Streaming(name="giyu selfbot v1.0", url="https://www.twitch.tv/giyu_selfbot"))
# Add Cogs
bot.add_cog(purge(bot))
bot.run("token", bot= False)
purge.py 代码:
import discord
import asyncio
from discord.ext import commands
class purge(commands.Cog):
def __init__(self, bot):
self.bot = bot
@commands.command(aliases=["clr", "p"])
async def purge(self, ctx, limit: int):
'''purge n messages, being n an integer'''
if limit <= 10:
total = limit +1
async for message in ctx.channel.history(limit=total):
if message.author == ctx.user:
await message.delete()
await asyncio.sleep(2)
await ctx.send(":man_with_probing_cane:")
else:
total = limit
async for message in ctx.channel.history(limit=total):
if message.author == ctx.user:
await message.delete()
await asyncio.sleep(2)
await ctx.send(":man_with_probing_cane:")
谁能帮我? 非常感谢:提前谢谢你:)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.