Repository: Cog-Creators/Red-DiscordBot

Issue:
[Downloader] Add embed version of `findcog`
# Feature request

<!-- This template is for feature requests. Please fill out the following: -->


#### Select the type of feature you are requesting:

<!-- To check a box, replace the space between the [] with a x -->

- [ ] Cog
- [x] Command
- [ ] API functionality

#### Describe your requested feature

An embed version of `[p]findcog`.

#### Aditional details

I'll do this at some point soonish, which likely will involve removing the function `format_findcog_info` ([L1317-1358](https://github.com/Cog-Creators/Red-DiscordBot/blob/f59e77002b33677b078a427b72acd5beb1598d24/redbot/cogs/downloader/downloader.py#L1317-1358)). If anyone has anything to add before I delve into downloader for the first time, speak now!
Draper also said I should look at L1346 and 1347 whilst in this area of the code:
```py
made_by = "26 & co."
repo_url = "https://github.com/Cog-Creators/Red-DiscordBot"


Discussion:
> An embed version of `[p]findcog`.

I don't see the need *personally*, but if it won't look terrible and the command will still be available when embeds are disabled, I guess I don't really mind. Hopefully it also won't take a lot more space than the non-embed version :P

> Draper also said I should look at L1346 and 1347 whilst in this area of the code

@Drapersniper what do you want to change about it?
> > An embed version of `[p]findcog`.
> 
> I don't see the need _personally_, but if it won't look terrible and the command will still be available when embeds are disabled, I guess I don't really mind. Hopefully it also won't take a lot more space than the non-embed version :P
> 
> > Draper also said I should look at L1346 and 1347 whilst in this area of the code
> 
> @Drapersniper what do you want to change about it?

 I would like to see core cogs keeping this while local cogs say local for the repo and n/a for author 
I'm thinking of something like this:
![This is the link to the image. You're looking at this is <#450749498231357450> aren't you? Well, either click me or open the comment on GH to see the image. Soz :/](http://i.vex.my.to/vYf1yd)
Yes, I know the branch name looks a bit out of place but most repos have v3 as the default branch so this isn't a big issue, in my opinion.

In terms of lines jack, it shouldn't be more than +10/20 or so as I'm taking out a function's docstring. Edit: Well actually you probably mean space in discord...
Or if you mean space in discord then look ^ - making them inline means its about the same if there's no repo branch
> Or if you mean space in discord then look ^ - making them inline means its about the same if there's no repo branch

yeah, that's what I meant, the amount of lines of code doesn't really matter unless you make it unnecessarily long 😄 

> I would like to see core cogs keeping this while local cogs say local for the repo and n/a for author

Yeah, that's fine, try not to forget about it, since this issue is focused on different thing :)

Probably the way to go about it would be checking cog's `__module__` for `redbot.cogs.`

Resolving patch:
diff --git a/redbot/cogs/downloader/downloader.py b/redbot/cogs/downloader/downloader.py
--- a/redbot/cogs/downloader/downloader.py
+++ b/redbot/cogs/downloader/downloader.py
@@ -1325,49 +1325,6 @@ async def _ask_for_cog_reload(self, ctx: commands.Context, updated_cognames: Set
 
         await ctx.invoke(ctx.bot.get_cog("Core").reload, *updated_cognames)
 
-    def format_findcog_info(
-        self, command_name: str, cog_installable: Union[Installable, object] = None
-    ) -> str:
-        """Format a cog's info for output to discord.
-
-        Parameters
-        ----------
-        command_name : str
-            Name of the command which belongs to the cog.
-        cog_installable : `Installable` or `object`
-            Can be an `Installable` instance or a Cog instance.
-
-        Returns
-        -------
-        str
-            A formatted message for the user.
-
-        """
-        if isinstance(cog_installable, Installable):
-            is_installable = True
-            made_by = ", ".join(cog_installable.author) or _("Missing from info.json")
-            repo_url = (
-                _("Missing from installed repos")
-                if cog_installable.repo is None
-                else cog_installable.repo.clean_url
-            )
-            cog_name = cog_installable.name
-        else:
-            is_installable = False
-            made_by = "26 & co."
-            repo_url = "https://github.com/Cog-Creators/Red-DiscordBot"
-            cog_name = cog_installable.__class__.__name__
-
-        msg = _(
-            "Command: {command}\nCog name: {cog}\nMade by: {author}\nRepo: {repo_url}\n"
-        ).format(command=command_name, author=made_by, repo_url=repo_url, cog=cog_name)
-        if is_installable and cog_installable.repo is not None and cog_installable.repo.branch:
-            msg += _("Repo branch: {branch_name}\n").format(
-                branch_name=cog_installable.repo.branch
-            )
-
-        return msg
-
     def cog_name_from_instance(self, instance: object) -> str:
         """Determines the cog name that Downloader knows from the cog instance.
 
@@ -1405,14 +1362,46 @@ async def findcog(self, ctx: commands.Context, command_name: str) -> None:
             cog_name = self.cog_name_from_instance(cog)
             installed, cog_installable = await self.is_installed(cog_name)
             if installed:
-                msg = self.format_findcog_info(command_name, cog_installable)
+                is_installable = True
+                made_by = humanize_list(cog_installable.author) or _("Missing from info.json")
+                repo_url = (
+                    _("Missing from installed repos")
+                    if cog_installable.repo is None
+                    else cog_installable.repo.clean_url
+                )
+                cog_name = cog_installable.name
             else:
                 # Assume it's in a base cog
-                msg = self.format_findcog_info(command_name, cog)
+                is_installable = False
+                made_by = "26 & co."
+                repo_url = "https://github.com/Cog-Creators/Red-DiscordBot"
+                cog_name = cog.__class__.__name__
         else:
             msg = _("This command is not provided by a cog.")
+            await ctx.send(msg)
+            return
 
-        await ctx.send(box(msg))
+        if await ctx.embed_requested():
+            embed = discord.Embed(color=(await ctx.embed_colour()))
+            embed.add_field(name=_("Command:"), value=command_name, inline=False)
+            embed.add_field(name=_("Cog Name:"), value=cog_name, inline=False)
+            embed.add_field(name=_("Made by:"), value=made_by, inline=False)
+            embed.add_field(name=_("Repo URL:"), value=repo_url, inline=False)
+            if is_installable and cog_installable.repo is not None and cog_installable.repo.branch:
+                embed.add_field(
+                    name=_("Repo branch:"), value=cog_installable.repo.branch, inline=False
+                )
+            await ctx.send(embed=embed)
+
+        else:
+            msg = _(
+                "Command: {command}\nCog name: {cog}\nMade by: {author}\nRepo URL: {repo_url}\n"
+            ).format(command=command_name, author=made_by, repo_url=repo_url, cog=cog_name)
+            if is_installable and cog_installable.repo is not None and cog_installable.repo.branch:
+                msg += _("Repo branch: {branch_name}\n").format(
+                    branch_name=cog_installable.repo.branch
+                )
+            await ctx.send(box(msg))
 
     @staticmethod
     def format_failed_repos(failed: Collection[str]) -> str:


Test patch: