1
0
Fork 0
mirror of https://github.com/uhIgnacio/EmoteManager.git synced 2024-08-15 02:23:13 +00:00

disable message cacheg

This commit is contained in:
io mintz 2020-10-01 06:06:43 +00:00
parent c3d92606ce
commit 0ae7331828
2 changed files with 11 additions and 13 deletions

2
bot.py
View file

@ -82,6 +82,8 @@ def main():
),
chunk_guilds_at_startup=False,
member_cache_flags=discord.MemberCacheFlags.none(),
# disable message cache
max_messages=None,
shard_count=shard_count,
shard_ids=shard_ids,

View file

@ -51,14 +51,15 @@ class Paginator:
self._page = None
def react_check(self, reaction, user):
if user is None or user != self.author:
def react_check(self, reaction: discord.RawReactionActionEvent):
if reaction.user_id != self.author.id:
return False
if reaction.message.id != self._message.id:
if reaction.message_id != self._message.id:
return False
return bool(discord.utils.find(lambda emoji: reaction.emoji == emoji, self.navigation))
target_emoji = str(reaction.emoji)
return bool(discord.utils.find(lambda emoji: target_emoji == emoji, self.navigation))
async def begin(self):
"""Starts pagination"""
@ -69,24 +70,19 @@ class Paginator:
await self._message.add_reaction(button)
while not self._stopped:
try:
reaction, user = await self._client.wait_for(
'reaction_add',
reaction: RawReactionActionEvent = await self._client.wait_for(
'raw_reaction_add',
check=self.react_check,
timeout=self.timeout)
except asyncio.TimeoutError:
await self.stop(delete=self.delete_msg_timeout)
continue
reaction = reaction.emoji
if reaction not in self.navigation:
continue # not worth our time
await self.navigation[reaction]()
await self.navigation[str(reaction.emoji)]()
await asyncio.sleep(0.2)
with contextlib.suppress(discord.HTTPException):
await self._message.remove_reaction(reaction, user)
await self._message.remove_reaction(reaction.emoji, discord.Object(reaction.user_id))
async def stop(self, *, delete=None):
"""Aborts pagination."""