Change emojis for book
This commit is contained in:
parent
0600b883fe
commit
8104302e43
@ -4,6 +4,7 @@ import asyncio
|
|||||||
import discord
|
import discord
|
||||||
from discord.ext.commands.formatter import Paginator as DannyPag
|
from discord.ext.commands.formatter import Paginator as DannyPag
|
||||||
from . import checks
|
from . import checks
|
||||||
|
from geeksbot import Geeksbot
|
||||||
import re
|
import re
|
||||||
import typing
|
import typing
|
||||||
|
|
||||||
@ -220,52 +221,41 @@ class Paginator:
|
|||||||
class Book:
|
class Book:
|
||||||
def __init__(self, pag: Paginator, ctx: typing.Tuple[discord.Message,
|
def __init__(self, pag: Paginator, ctx: typing.Tuple[discord.Message,
|
||||||
discord.TextChannel,
|
discord.TextChannel,
|
||||||
discord.ext.commands.Bot]):
|
Geeksbot,
|
||||||
|
discord.Message]) -> None:
|
||||||
if pag == Paginator():
|
if pag == Paginator():
|
||||||
raise RuntimeError('Cannot create a book out of an empty Paginator.')
|
raise RuntimeError('Cannot create a book out of an empty Paginator.')
|
||||||
|
|
||||||
self._pages = pag.process_pages()
|
self._pages = pag.process_pages()
|
||||||
self._len_pages = len(self._pages)
|
self._len_pages = len(self._pages)
|
||||||
self._current_page = 0
|
self._current_page = 0
|
||||||
self._message, self._channel, self._bot = ctx
|
self._message, self._channel, self._bot, self._calling_message = ctx
|
||||||
self._locked = True
|
self._locked = True
|
||||||
|
|
||||||
def advance_page(self, count: int=1):
|
def advance_page(self) -> None:
|
||||||
self._current_page += count
|
self._current_page += 1
|
||||||
if self._current_page >= self._len_pages:
|
if self._current_page >= self._len_pages:
|
||||||
self._current_page = self._len_pages
|
|
||||||
|
|
||||||
def reverse_page(self, count: int=1):
|
|
||||||
self._current_page -= count
|
|
||||||
if self._current_page <= 0:
|
|
||||||
self._current_page = 0
|
self._current_page = 0
|
||||||
|
|
||||||
async def display_page(self):
|
def reverse_page(self) -> None:
|
||||||
await self._message.edit(content=self._pages[self._current_page])
|
self._current_page += -1
|
||||||
|
if self._current_page < 0:
|
||||||
|
self._current_page = self._len_pages - 1
|
||||||
|
|
||||||
try:
|
async def display_page(self) -> None:
|
||||||
if not self._current_page == 0:
|
if isinstance(self._pages[self._current_page], discord.Embed):
|
||||||
await self._message.add_reaction(self._bot.unicode_emojis['start'])
|
await self._message.edit(content=None, embed=self._pages[self._current_page])
|
||||||
if not self._current_page < 10:
|
|
||||||
await self._message.add_reaction(self._bot.unicode_emojis['rewind'])
|
|
||||||
if not self._current_page == 0:
|
|
||||||
await self._message.add_reaction(self._bot.unicode_emojis['back'])
|
|
||||||
if self._len_pages > 1:
|
|
||||||
await self._message.add_reaction(self._bot.unicode_emojis['hash'])
|
|
||||||
if not self._current_page == self._len_pages - 1:
|
|
||||||
await self._message.add_reaction(self._bot.unicode_emojis['forward'])
|
|
||||||
if not self._current_page > self._len_pages - 11:
|
|
||||||
await self._message.add_reaction(self._bot.unicode_emojis['fast_forward'])
|
|
||||||
if not self._current_page == self._len_pages - 1:
|
|
||||||
await self._message.add_reaction(self._bot.unicode_emojis['end'])
|
|
||||||
await self._message.add_reaction(self._bot.unicode_emojis['close'])
|
|
||||||
if self._locked:
|
|
||||||
await self._message.add_reaction(self._bot.unicode_emojis['open_lock'])
|
|
||||||
else:
|
else:
|
||||||
await self._message.add_reaction(self._bot.unicode_emojis['lock'])
|
await self._message.edit(content=self._pages[self._current_page], embed=None)
|
||||||
|
|
||||||
|
for reaction in self._bot.book_emojis:
|
||||||
|
try:
|
||||||
|
await self._message.add_reaction(reaction)
|
||||||
except (discord.Forbidden, KeyError):
|
except (discord.Forbidden, KeyError):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
# async def create_book(self) -> None:
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
20
geeksbot.py
20
geeksbot.py
@ -1,4 +1,4 @@
|
|||||||
from typing import Dict
|
from typing import Dict, List
|
||||||
|
|
||||||
import discord
|
import discord
|
||||||
from discord.ext import commands
|
from discord.ext import commands
|
||||||
@ -80,16 +80,16 @@ class Geeksbot(commands.Bot):
|
|||||||
'boom': '💥',
|
'boom': '💥',
|
||||||
'left_fist': '🤛',
|
'left_fist': '🤛',
|
||||||
'lock': '🔒',
|
'lock': '🔒',
|
||||||
'open_lock': '🔓',
|
|
||||||
'back': '◀',
|
|
||||||
'forward': '▶',
|
|
||||||
'fast_forward': '⏩',
|
|
||||||
'rewind': '⏪',
|
|
||||||
'end': '⏭',
|
|
||||||
'start': '⏮',
|
|
||||||
'hash': '#\N{COMBINING ENCLOSING KEYCAP}',
|
|
||||||
'close': '🇽',
|
|
||||||
}
|
}
|
||||||
|
self.book_emojis: List[str] = [
|
||||||
|
'🔓',
|
||||||
|
'⏮',
|
||||||
|
'◀',
|
||||||
|
'#\N{COMBINING ENCLOSING KEYCAP}',
|
||||||
|
'▶',
|
||||||
|
'⏭',
|
||||||
|
'🇽',
|
||||||
|
]
|
||||||
|
|
||||||
async def logout(self):
|
async def logout(self):
|
||||||
await self.db_con.close()
|
await self.db_con.close()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user