如何修复“ Bot对象没有属性logs_from”

时间:2019-05-27 07:04:01

标签: python-3.x discord.py

我一直在尝试使用discord.py制作机器人,我想制作一条删除x条消息的命令。但是,logs_from无法识别为bot对象的属性。

我在网上搜索,使用logs_from似乎每个人都没有问题。

import discord
from discord.ext import commands
from discord.ext.commands import Bot

Client = discord.Client() 
bot = commands.Bot(command_prefix=">")

@bot.command(pass_context=True,)
async def purge(ctx, number):
    number = int(number)
    if number > 99 or number < 1:
        await ctx.send("I can only delete messages within a range of 1 - 99")
    else:
        author = ctx.message.author
        authorID = author.id
        mgs = []
        number = int(number)
        channel = ctx.message.channel
        async for x in bot.logs_from((channel), limit = int(number+1)):
            mgs.append(x)
        await delete_messages(mgs)
        await ctx.send('Messages deleted!', delete_after=4)```

1 个答案:

答案 0 :(得分:0)

作为有状态模型更改的一部分,Client.logs_from已替换为Messageable.history

如果您想将旧资料改编为新版本的discord.py,则应阅读migration guide