Repository: Cog-Creators/Red-DiscordBot

Issue:
Expose `[p]inviteset` Functionality (for Cogs)
### Type of feature request

API functionality

### Description of the feature you're suggesting

Currently, there is no supported method for third-party cogs to utilize the bot's settings for `[p]inviteset` in order to generate invite links with the same permissions and scopes as `[p]invite`. It would be great if either the settings/config info or the [link-generation function](https://github.com/Cog-Creators/Red-DiscordBot/blob/52f96e043bb43de9d5bb12d6c9dfdb34fb1cbf4d/redbot/core/core_commands.py#L372) were exposed for cogs to utilize.

### Anything else?

An example where this would be useful is in my [BotAccess](https://github.com/Obi-Wan3/OB13-Cogs/blob/400d75b932b0a1a508ed63943fdff082ee2b42a7/botaccess/botaccess.py#L195) cog, where server supporters are granted the ability to invite the bot to a limited number of their own servers. However, without this endpoint, either the generated invite link would be the "default" or `[p]inviteset` would need to be re-implemented.


Discussion:
This would be a good thing to have a public method for.

I also have a cog that try to use [p]inviteset to generate invite permission scope, so this is something I do find very useful for.
Do you just want the current invite URL or some invite util that you can use to generate invite links by passing it permissions etc? 
> Do you just want the current invite URL or some invite util that you can use to generate invite links by passing it permissions etc?

The current one set in core, there's already an util in `discord.utils` iirc to generate invite links

Resolving patch:
diff --git a/redbot/core/bot.py b/redbot/core/bot.py
--- a/redbot/core/bot.py
+++ b/redbot/core/bot.py
@@ -1305,6 +1305,37 @@ async def is_owner(self, user: Union[discord.User, discord.Member]) -> bool:
         """
         return user.id in self.owner_ids
 
+    async def get_invite_url(self) -> str:
+        """
+        Generates the invite URL for the bot.
+
+        Does not check if the invite URL is configured to be public
+        with ``[p]inviteset public``. To check if invites are public,
+        use `Red.is_invite_url_public()`.
+
+        Returns
+        -------
+        str
+            Invite URL.
+        """
+        data = await self._config.all()
+        commands_scope = data["invite_commands_scope"]
+        scopes = ("bot", "applications.commands") if commands_scope else None
+        perms_int = data["invite_perm"]
+        permissions = discord.Permissions(perms_int)
+        return discord.utils.oauth_url(self._app_info.id, permissions, scopes=scopes)
+
+    async def is_invite_url_public(self) -> bool:
+        """
+        Determines if invite URL is configured to be public with ``[p]inviteset public``.
+
+        Returns
+        -------
+        bool
+            :code:`True` if the invite URL is public.
+        """
+        return await self._config.invite_public()
+
     async def is_admin(self, member: discord.Member) -> bool:
         """Checks if a member is an admin of their guild."""
         try:
diff --git a/redbot/core/core_commands.py b/redbot/core/core_commands.py
--- a/redbot/core/core_commands.py
+++ b/redbot/core/core_commands.py
@@ -381,13 +381,7 @@ async def _invite_url(self) -> str:
         str
             Invite URL.
         """
-        app_info = await self.bot.application_info()
-        data = await self.bot._config.all()
-        commands_scope = data["invite_commands_scope"]
-        scopes = ("bot", "applications.commands") if commands_scope else None
-        perms_int = data["invite_perm"]
-        permissions = discord.Permissions(perms_int)
-        return discord.utils.oauth_url(app_info.id, permissions, scopes=scopes)
+        return await self.bot.get_invite_url()
 
     @staticmethod
     async def _can_get_invite_url(ctx):
@@ -1487,7 +1481,7 @@ async def invite(self, ctx):
             - `[p]invite`
         """
         try:
-            await ctx.author.send(await self._invite_url())
+            await ctx.author.send(await self.bot.get_invite_url())
             await ctx.tick()
         except discord.errors.Forbidden:
             await ctx.send(


Test patch: