# Path: Cogs/Message.py
# class Message:
#     def __init__(self, **kwargs):
#         # Creates a new message - with an optional setup dictionary
#         self.max_chars = 2000
#         self.pm_after = kwargs.get("pm_after", 1) # -1 to disable, 0 to always pm
#         self.force_pm = kwargs.get("force_pm", False)
#         self.header = kwargs.get("header", "")
#         self.footer = kwargs.get("footer", "")
#         self.pm_react = kwargs.get("pm_react", "📬")
#         self.message = kwargs.get("message", None)
#         self.file = kwargs.get("file", None) # Accepts a file path
#         self.max_pages = 0
#         self.delete_after = kwargs.get("delete_after",None)
# 
#     def _get_file(self, file_path):
#         if not os.path.exists(file_path):
#             return None
#         # Path exists, let's get the extension if there is one
#         ext = file_path.split(".")
#         fname = "Upload." + ext[-1] if len(ext) > 1 else "Upload"
#         file_handle = discord.File(fp=file_path, filename=fname)
#         return (file_handle, fname)
# 
#     async def _send_message(self, ctx, message, pm = False, file_path = None):
#         # Helper method to send embeds to their proper location
#         send_file = None
#         if not file_path == None:
#             dfile = self._get_file(file_path)
#             if not dfile:
#                 # File doesn't exist...
#                 try:
#                     await ctx.send("An error occurred!\nThe file specified couldn't be sent :(")
#                 except:
#                     # We tried...
#                     pass
#                 return None
#             else:
#                 # Setup our file
#                 send_file = dfile[0]
#         if pm == True and type(ctx) is discord.ext.commands.Context and not ctx.channel == ctx.author.dm_channel:
#             # More than 2 pages - try to dm
#             try:
#                 message = await ctx.author.send(message, file=send_file, delete_after=self.delete_after)
#                 await ctx.message.add_reaction(self.pm_react)
#                 return message
#             except discord.Forbidden:
#                 if self.force_pm:
#                     # send an error message
#                     try:
#                         await ctx.send("An error occurred!\nCould not dm this message to you :(")
#                     except:
#                         # We tried...
#                         pass
#                     return None
#                 pass
#         return await ctx.send(message, file=send_file, delete_after=self.delete_after)
# 
#     async def send(self, ctx):
#         if not ctx or not self.message or not len(self.message):
#             return
#         text_list = textwrap.wrap(
#             self.message,
#             self.max_chars - len(self.header) - len(self.footer),
#             break_long_words=True,
#             replace_whitespace=False)
# 
#         # Only pm if our self.pm_after is above -1
#         to_pm = len(text_list) > self.pm_after if self.pm_after > -1 else False
#         page_count = 1
#         for m in text_list:
#             if self.max_pages > 0 and page_count > self.max_pages:
#                 break
#             message = await self._send_message(ctx, self.header + m + self.footer, to_pm)
#             # Break if things didn't work
#             if not message:
#                 return None
#             page_count += 1
#         return message


import asyncio, discord, math, textwrap
from   discord.ext import commands
from   Cogs import Message

        return [self.d_header+x+self.d_footer for x in textwrap.wrap(
            self.description,
            adj_max,
            break_long_words=True,
            replace_whitespace=False
        )]

    def _get_page_contents(self, page_number):
        # Returns the contents of the page passed
        if self.list:
            start = self.max*page_number
            return self.list[start:start+self.max]
        return self._get_desc_page_list()[page_number]

    def _get_footer(self, page, pages):
        if pages <= 1: return self.footer
        return "[{:,}/{:,}] - {}".format(page+1,pages,self.footer) if self.footer else "Page {:,} of {:,}".format(page+1,pages)

    async def pick(self):
        # This brings up the page picker and handles the events
        # It will return a tuple of (last_page_seen, message)
        # The return code is -1 for cancel, -2 for timeout, -3 for error, 0+ is index
        # Let's check our prerequisites first
        if self.ctx == None or (not self.list and not self.description):
            return (-3, None)
        page  = 0 # Set the initial page index
        if self.list:
            pages = int(math.ceil(len(self.list)/self.max))
        else:
            pages = len(self._get_desc_page_list())

# Path: Cogs/Message.py
# class Message:
#     def __init__(self, **kwargs):
#         # Creates a new message - with an optional setup dictionary
#         self.max_chars = 2000
#         self.pm_after = kwargs.get("pm_after", 1) # -1 to disable, 0 to always pm
#         self.force_pm = kwargs.get("force_pm", False)
#         self.header = kwargs.get("header", "")
#         self.footer = kwargs.get("footer", "")
#         self.pm_react = kwargs.get("pm_react", "📬")
#         self.message = kwargs.get("message", None)
#         self.file = kwargs.get("file", None) # Accepts a file path
#         self.max_pages = 0
#         self.delete_after = kwargs.get("delete_after",None)
# 
#     def _get_file(self, file_path):
#         if not os.path.exists(file_path):
#             return None
#         # Path exists, let's get the extension if there is one
#         ext = file_path.split(".")
#         fname = "Upload." + ext[-1] if len(ext) > 1 else "Upload"
#         file_handle = discord.File(fp=file_path, filename=fname)
#         return (file_handle, fname)
# 
#     async def _send_message(self, ctx, message, pm = False, file_path = None):
#         # Helper method to send embeds to their proper location
#         send_file = None
#         if not file_path == None:
#             dfile = self._get_file(file_path)
#             if not dfile:
#                 # File doesn't exist...
#                 try:
#                     await ctx.send("An error occurred!\nThe file specified couldn't be sent :(")
#                 except:
#                     # We tried...
#                     pass
#                 return None
#             else:
#                 # Setup our file
#                 send_file = dfile[0]
#         if pm == True and type(ctx) is discord.ext.commands.Context and not ctx.channel == ctx.author.dm_channel:
#             # More than 2 pages - try to dm
#             try:
#                 message = await ctx.author.send(message, file=send_file, delete_after=self.delete_after)
#                 await ctx.message.add_reaction(self.pm_react)
#                 return message
#             except discord.Forbidden:
#                 if self.force_pm:
#                     # send an error message
#                     try:
#                         await ctx.send("An error occurred!\nCould not dm this message to you :(")
#                     except:
#                         # We tried...
#                         pass
#                     return None
#                 pass
#         return await ctx.send(message, file=send_file, delete_after=self.delete_after)
# 
#     async def send(self, ctx):
#         if not ctx or not self.message or not len(self.message):
#             return
#         text_list = textwrap.wrap(
#             self.message,
#             self.max_chars - len(self.header) - len(self.footer),
#             break_long_words=True,
#             replace_whitespace=False)
# 
#         # Only pm if our self.pm_after is above -1
#         to_pm = len(text_list) > self.pm_after if self.pm_after > -1 else False
#         page_count = 1
#         for m in text_list:
#             if self.max_pages > 0 and page_count > self.max_pages:
#                 break
#             message = await self._send_message(ctx, self.header + m + self.footer, to_pm)
#             # Break if things didn't work
#             if not message:
#                 return None
#             page_count += 1
#         return message


# Path: Cogs/PickList.py
import asyncio, discord, math, textwrap
from   discord.ext import commands
from   Cogs import Message

        return [self.d_header+x+self.d_footer for x in textwrap.wrap(
            self.description,
            adj_max,
            break_long_words=True,
            replace_whitespace=False
        )]

    def _get_page_contents(self, page_number):
        # Returns the contents of the page passed
        if self.list:
            start = self.max*page_number
            return self.list[start:start+self.max]
        return self._get_desc_page_list()[page_number]

    def _get_footer(self, page, pages):
        if pages <= 1: return self.footer
        return "[{:,}/{:,}] - {}".format(page+1,pages,self.footer) if self.footer else "Page {:,} of {:,}".format(page+1,pages)

    async def pick(self):
        # This brings up the page picker and handles the events
        # It will return a tuple of (last_page_seen, message)
        # The return code is -1 for cancel, -2 for timeout, -3 for error, 0+ is index
        # Let's check our prerequisites first
        if self.ctx == None or (not self.list and not self.description):
            return (-3, None)
        page  = 0 # Set the initial page index
        if self.list:
            pages = int(math.ceil(len(self.list)/self.max))
        else:
            pages = len(self._get_desc_page_list())

        embed_class = Message.Embed if self.list else Message.EmbedText
