mirror of
https://github.com/Paillat-dev/Botator.git
synced 2026-01-02 01:06:19 +00:00
28 lines
808 B
Python
28 lines
808 B
Python
|
|
import discord
|
||
|
|
|
||
|
|
|
||
|
|
def is_ignorable(content):
|
||
|
|
if content.startswith("-") or content.startswith("//"):
|
||
|
|
return True
|
||
|
|
return False
|
||
|
|
|
||
|
|
|
||
|
|
async def fetch_messages_history(
|
||
|
|
channel: discord.TextChannel, limit: int, original_message: discord.Message
|
||
|
|
) -> list[discord.Message]:
|
||
|
|
messages = []
|
||
|
|
if original_message == None:
|
||
|
|
async for msg in channel.history(limit=100):
|
||
|
|
if not is_ignorable(msg.content):
|
||
|
|
messages.append(msg)
|
||
|
|
if len(messages) == limit:
|
||
|
|
break
|
||
|
|
else:
|
||
|
|
async for msg in channel.history(limit=100, before=original_message):
|
||
|
|
if not is_ignorable(msg.content):
|
||
|
|
messages.append(msg)
|
||
|
|
if len(messages) == limit:
|
||
|
|
break
|
||
|
|
messages.reverse()
|
||
|
|
return messages
|