mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-06 03:08:55 -05:00
[Core] Add toggle for the applications.commands invite scope (#5114)
* Add toggle for applications.commands invite scope * Add support for i18n * Fix formatting Co-authored-by: Kowlin <boxedpp@gmail.com>
This commit is contained in:
parent
1ee4156ac6
commit
0ce2634bb3
@ -118,6 +118,7 @@ class RedBase(
|
||||
description="Red V3",
|
||||
invite_public=False,
|
||||
invite_perm=0,
|
||||
invite_commands_scope=False,
|
||||
disabled_commands=[],
|
||||
disabled_command_msg="That command is disabled.",
|
||||
extra_owner_destinations=[],
|
||||
|
||||
@ -377,9 +377,12 @@ class CoreLogic:
|
||||
Invite URL.
|
||||
"""
|
||||
app_info = await self.bot.application_info()
|
||||
perms_int = await self.bot._config.invite_perm()
|
||||
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)
|
||||
return discord.utils.oauth_url(app_info.id, permissions, scopes=scopes)
|
||||
|
||||
@staticmethod
|
||||
async def _can_get_invite_url(ctx):
|
||||
@ -1565,6 +1568,26 @@ class Core(commands.commands._RuleDropper, commands.Cog, CoreLogic):
|
||||
await self.bot._config.invite_perm.set(level)
|
||||
await ctx.send("The new permissions level has been set.")
|
||||
|
||||
@inviteset.command()
|
||||
async def commandscope(self, ctx: commands.Context):
|
||||
"""
|
||||
Add the `applications.commands` scope to your invite URL.
|
||||
|
||||
This allows the usage of slash commands on the servers that invited your bot with that scope.
|
||||
|
||||
Note that previous servers that invited the bot without the scope cannot have slash commands, they will have to invite the bot a second time.
|
||||
"""
|
||||
enabled = not await self.bot._config.invite_commands_scope()
|
||||
await self.bot._config.invite_commands_scope.set(enabled)
|
||||
if enabled is True:
|
||||
await ctx.send(
|
||||
_("The `applications.commands` scope has been added to the invite URL.")
|
||||
)
|
||||
else:
|
||||
await ctx.send(
|
||||
_("The `applications.commands` scope has been removed from the invite URL.")
|
||||
)
|
||||
|
||||
@commands.command()
|
||||
@checks.is_owner()
|
||||
async def leave(self, ctx: commands.Context, *servers: GuildConverter):
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user