async for ... in history(...)
:
https://discordpy.readthedocs.io/en/stable/api.htm...
counter = 0
async for message in channel.history(limit=200):
if message.author == client.user:
counter += 1
messages = await channel.history(limit=123).flatten()
# messages is now a list of Message...
Для получения сообщений за последние 2 часа:
from datetime import datetime, timedelta
# ...
async for message in channel.history(
limit=None, # If None, retrieves every message in the channel. Note, however, that this would make it a slow operation.
after=datetime.utcnow()-timedelta(hours=2) # If a date is provided it must be a timezone-naive datetime representing UTC time. (https://docs.python.org/3/library/datetime.html#datetime.datetime.utcnow)
):