Flare
Flare

Reputation: 23

How to fix "Bot object has no attribute logs_from"

I've been trying to make a bot using discord.py, I want to make a command that deletes x number of messages. However, logs_from is not recognized as an attribute for the bot object.

I searched online and everyone seemed to have no problem using 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)```

Upvotes: 2

Views: 3181

Answers (1)

Patrick Haugh
Patrick Haugh

Reputation: 60944

As part of the stateful model changes, Client.logs_from has been replaced with Messageable.history.

If you're trying to adapt old materials into the newer versions of discord.py, you should read the migration guide.

Upvotes: 1

Related Questions