diff --git a/redbot/core/bot.py b/redbot/core/bot.py index 32b22b80a..8e47a6a17 100644 --- a/redbot/core/bot.py +++ b/redbot/core/bot.py @@ -1273,6 +1273,37 @@ class Red( """ 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 index 2406e1eec..91fe5af0b 100644 --- a/redbot/core/core_commands.py +++ b/redbot/core/core_commands.py @@ -362,13 +362,7 @@ class CoreLogic: 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): @@ -1465,7 +1459,7 @@ class Core(commands.commands._RuleDropper, commands.Cog, CoreLogic): - `[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(