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:
parent
c3d92606ce
commit
0ae7331828
2 changed files with 11 additions and 13 deletions
2
bot.py
2
bot.py
|
@ -82,6 +82,8 @@ def main():
|
||||||
),
|
),
|
||||||
chunk_guilds_at_startup=False,
|
chunk_guilds_at_startup=False,
|
||||||
member_cache_flags=discord.MemberCacheFlags.none(),
|
member_cache_flags=discord.MemberCacheFlags.none(),
|
||||||
|
# disable message cache
|
||||||
|
max_messages=None,
|
||||||
|
|
||||||
shard_count=shard_count,
|
shard_count=shard_count,
|
||||||
shard_ids=shard_ids,
|
shard_ids=shard_ids,
|
||||||
|
|
|
@ -51,14 +51,15 @@ class Paginator:
|
||||||
|
|
||||||
self._page = None
|
self._page = None
|
||||||
|
|
||||||
def react_check(self, reaction, user):
|
def react_check(self, reaction: discord.RawReactionActionEvent):
|
||||||
if user is None or user != self.author:
|
if reaction.user_id != self.author.id:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
if reaction.message.id != self._message.id:
|
if reaction.message_id != self._message.id:
|
||||||
return False
|
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):
|
async def begin(self):
|
||||||
"""Starts pagination"""
|
"""Starts pagination"""
|
||||||
|
@ -69,24 +70,19 @@ class Paginator:
|
||||||
await self._message.add_reaction(button)
|
await self._message.add_reaction(button)
|
||||||
while not self._stopped:
|
while not self._stopped:
|
||||||
try:
|
try:
|
||||||
reaction, user = await self._client.wait_for(
|
reaction: RawReactionActionEvent = await self._client.wait_for(
|
||||||
'reaction_add',
|
'raw_reaction_add',
|
||||||
check=self.react_check,
|
check=self.react_check,
|
||||||
timeout=self.timeout)
|
timeout=self.timeout)
|
||||||
except asyncio.TimeoutError:
|
except asyncio.TimeoutError:
|
||||||
await self.stop(delete=self.delete_msg_timeout)
|
await self.stop(delete=self.delete_msg_timeout)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
reaction = reaction.emoji
|
await self.navigation[str(reaction.emoji)]()
|
||||||
|
|
||||||
if reaction not in self.navigation:
|
|
||||||
continue # not worth our time
|
|
||||||
|
|
||||||
await self.navigation[reaction]()
|
|
||||||
|
|
||||||
await asyncio.sleep(0.2)
|
await asyncio.sleep(0.2)
|
||||||
with contextlib.suppress(discord.HTTPException):
|
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):
|
async def stop(self, *, delete=None):
|
||||||
"""Aborts pagination."""
|
"""Aborts pagination."""
|
||||||
|
|
Loading…
Reference in a new issue