繁体   English   中英

Discord.py 清除命令未清除(selfbot)

[英]Discord.py purge command not purging (selfbot)

所以我一直在尝试为 Discord 制作一个自我机器人,但我的代码没有成功,我有点想了解哪里出了问题。 我正在尝试编写清除命令并发生以下情况:

  1. 当其他用户调用它而不是我时,机器人会做出反应;
  2. 当我调用它时,它根本没有反应或记录命令或任何错误;
  3. 它出现了一个错误,说 purge.py 中的“上下文”没有属性。

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM