# Path: quotetools/helpers.py
# def embed_from_msg(message: discord.Message) -> discord.Embed:
#     channel = message.channel
#     assert isinstance(channel, discord.TextChannel), "mypy"  # nosec
#     guild = channel.guild
#     content = role_mention_cleanup(message)
#     author = message.author
#     avatar = author.avatar_url
#     footer = f"Said in {guild.name} #{channel.name}"
# 
#     try:
#         color = author.color if author.color.value != 0 else None
#     except AttributeError:  # happens if message author not in guild anymore.
#         color = None
#     em = discord.Embed(description=content, timestamp=message.created_at)
#     if color:
#         em.color = color
# 
#     em.set_author(name=f"{author.name}", icon_url=avatar)
#     em.set_footer(icon_url=guild.icon_url, text=footer)
#     if message.attachments:
#         a = message.attachments[0]
#         fname = a.filename
#         url = a.url
#         if fname.split(".")[-1] in ["png", "jpg", "gif", "jpeg"]:
#             em.set_image(url=url)
#         else:
#             em.add_field(
#                 name="Message has an attachment", value=f"[{fname}]({url})", inline=True
#             )
#     em.add_field(
#         name="Does this appear to be out of context?",
#         value=f"[Click to jump to original message]({message.jump_url})",
#         inline=False,
#     )
#     return em
# 
# async def find_messages(
#     ctx: commands.Context,
#     ids: Sequence[int],
#     channels: Optional[Sequence[discord.TextChannel]] = None,
# ) -> Sequence[discord.Message]:
# 
#     channels = channels or await eligible_channels(ctx)
# 
#     # dict order preserved py3.6+
#     accumulated: Dict[int, Optional[discord.Message]] = {i: None for i in ids}
# 
#     # This can find ineligible messages, but we strip later to avoid researching
#     accumulated.update({m.id: m for m in ctx.bot.cached_messages if m.id in ids})
# 
#     for i in ids:
#         if accumulated[i] is not None:
#             continue
#         m = await find_msg_fallback(channels, i)
#         if m:
#             accumulated[i] = m
# 
#     filtered = [m for m in accumulated.values() if m and m.channel in channels]
#     return filtered


import re
import discord
from typing import NamedTuple
from redbot.core import commands
from .helpers import embed_from_msg, find_messages
        pre_processed = super().format_help_for_context(ctx)
        return f"{pre_processed}\nCog Version: {self.__version__}"

    def __init__(self, bot, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.bot = bot

    @commands.command()
    async def quote(
        self, ctx, channels: commands.Greedy[GlobalTextChannel] = None, *messageids: int
    ):
        """
        gets (a) message(s) by ID(s)

        User must be able to see the message(s)

        You need to specify specific channels to search (by ID or mention only!)
        """

        if not messageids or not channels:
            return await ctx.send_help()

        chans = [c.matched_channel for c in channels]

        msgs = await find_messages(ctx, messageids, chans)
        if not msgs:
            return await ctx.maybe_send_embed("No matching message found.")

        for m in msgs:
            if await ctx.embed_requested():

# Path: quotetools/helpers.py
# def embed_from_msg(message: discord.Message) -> discord.Embed:
#     channel = message.channel
#     assert isinstance(channel, discord.TextChannel), "mypy"  # nosec
#     guild = channel.guild
#     content = role_mention_cleanup(message)
#     author = message.author
#     avatar = author.avatar_url
#     footer = f"Said in {guild.name} #{channel.name}"
# 
#     try:
#         color = author.color if author.color.value != 0 else None
#     except AttributeError:  # happens if message author not in guild anymore.
#         color = None
#     em = discord.Embed(description=content, timestamp=message.created_at)
#     if color:
#         em.color = color
# 
#     em.set_author(name=f"{author.name}", icon_url=avatar)
#     em.set_footer(icon_url=guild.icon_url, text=footer)
#     if message.attachments:
#         a = message.attachments[0]
#         fname = a.filename
#         url = a.url
#         if fname.split(".")[-1] in ["png", "jpg", "gif", "jpeg"]:
#             em.set_image(url=url)
#         else:
#             em.add_field(
#                 name="Message has an attachment", value=f"[{fname}]({url})", inline=True
#             )
#     em.add_field(
#         name="Does this appear to be out of context?",
#         value=f"[Click to jump to original message]({message.jump_url})",
#         inline=False,
#     )
#     return em
# 
# async def find_messages(
#     ctx: commands.Context,
#     ids: Sequence[int],
#     channels: Optional[Sequence[discord.TextChannel]] = None,
# ) -> Sequence[discord.Message]:
# 
#     channels = channels or await eligible_channels(ctx)
# 
#     # dict order preserved py3.6+
#     accumulated: Dict[int, Optional[discord.Message]] = {i: None for i in ids}
# 
#     # This can find ineligible messages, but we strip later to avoid researching
#     accumulated.update({m.id: m for m in ctx.bot.cached_messages if m.id in ids})
# 
#     for i in ids:
#         if accumulated[i] is not None:
#             continue
#         m = await find_msg_fallback(channels, i)
#         if m:
#             accumulated[i] = m
# 
#     filtered = [m for m in accumulated.values() if m and m.channel in channels]
#     return filtered


# Path: quotetools/quotetools.py
import re
import discord
from typing import NamedTuple
from redbot.core import commands
from .helpers import embed_from_msg, find_messages

        pre_processed = super().format_help_for_context(ctx)
        return f"{pre_processed}\nCog Version: {self.__version__}"

    def __init__(self, bot, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.bot = bot

    @commands.command()
    async def quote(
        self, ctx, channels: commands.Greedy[GlobalTextChannel] = None, *messageids: int
    ):
        """
        gets (a) message(s) by ID(s)

        User must be able to see the message(s)

        You need to specify specific channels to search (by ID or mention only!)
        """

        if not messageids or not channels:
            return await ctx.send_help()

        chans = [c.matched_channel for c in channels]

        msgs = await find_messages(ctx, messageids, chans)
        if not msgs:
            return await ctx.maybe_send_embed("No matching message found.")

        for m in msgs:
            if await ctx.embed_requested():

                em = embed_from_msg(m)