mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-06 03:08:55 -05:00
[V3 Core] More features for the bot invite URL (#1847)
* Add inviteset group command * Fix errors * Fix line break * Remove user bot support * Fix docstrings line breaks * Remove embed specific formatting * Remove invite redirect * Add self argument to _can_get_invite_url * Remove unused import * fix errors related to classes + double help * Removed self bot support
This commit is contained in:
parent
463d8d6306
commit
61b5730c48
@ -60,6 +60,8 @@ class RedBase(commands.GroupMixin, commands.bot.BotBase, RPCMixin): # pylint: d
|
||||
help__verify_checks=True,
|
||||
help__verify_exists=False,
|
||||
help__tagline="",
|
||||
invite_public=False,
|
||||
invite_perm=0,
|
||||
disabled_commands=[],
|
||||
disabled_command_msg="That command is disabled.",
|
||||
api_tokens={},
|
||||
|
||||
@ -265,7 +265,15 @@ class CoreLogic:
|
||||
Invite URL.
|
||||
"""
|
||||
app_info = await self.bot.application_info()
|
||||
return discord.utils.oauth_url(app_info.id)
|
||||
perms_int = await self.bot.db.invite_perm()
|
||||
permissions = discord.Permissions(perms_int)
|
||||
return discord.utils.oauth_url(app_info.id, permissions)
|
||||
|
||||
@staticmethod
|
||||
async def _can_get_invite_url(ctx):
|
||||
is_owner = await ctx.bot.is_owner(ctx.author)
|
||||
is_invite_public = await ctx.bot.db.invite_public()
|
||||
return is_owner or is_invite_public
|
||||
|
||||
|
||||
@i18n.cog_i18n(_)
|
||||
@ -441,11 +449,65 @@ class Core(commands.Cog, CoreLogic):
|
||||
await ctx.send(_("No exception has occurred yet"))
|
||||
|
||||
@commands.command()
|
||||
@checks.is_owner()
|
||||
async def invite(self, ctx: commands.Context):
|
||||
@commands.check(CoreLogic._can_get_invite_url)
|
||||
async def invite(self, ctx):
|
||||
"""Show's Red's invite url"""
|
||||
await ctx.author.send(await self._invite_url())
|
||||
|
||||
@commands.group()
|
||||
@checks.is_owner()
|
||||
async def inviteset(self, ctx):
|
||||
"""Setup the bot's invite"""
|
||||
pass
|
||||
|
||||
@inviteset.command()
|
||||
async def public(self, ctx, confirm: bool = False):
|
||||
"""
|
||||
Define if the command should be accessible\
|
||||
for the average users.
|
||||
"""
|
||||
if await self.bot.db.invite_public():
|
||||
await self.bot.db.invite_public.set(False)
|
||||
await ctx.send("The invite is now private.")
|
||||
return
|
||||
app_info = await self.bot.application_info()
|
||||
if not app_info.bot_public:
|
||||
await ctx.send(
|
||||
"I am not a public bot. That means that nobody except "
|
||||
"you can invite me on new servers.\n\n"
|
||||
"You can change this by ticking `Public bot` in "
|
||||
"your token settings: "
|
||||
"https://discordapp.com/developers/applications/me/{0}".format(self.bot.user.id)
|
||||
)
|
||||
return
|
||||
if not confirm:
|
||||
await ctx.send(
|
||||
"You're about to make the `{0}invite` command public. "
|
||||
"All users will be able to invite me on their server.\n\n"
|
||||
"If you agree, you can type `{0}inviteset public yes`.".format(ctx.prefix)
|
||||
)
|
||||
else:
|
||||
await self.bot.db.invite_public.set(True)
|
||||
await ctx.send("The invite command is now public.")
|
||||
|
||||
@inviteset.command()
|
||||
async def perms(self, ctx, level: int):
|
||||
"""
|
||||
Make the bot create its own role with permissions on join.
|
||||
|
||||
The bot will create its own role with the desired permissions\
|
||||
when he join a new server. This is a special role that can't be\
|
||||
deleted or removed from the bot.
|
||||
|
||||
For that, you need to give a valid permissions level.
|
||||
You can generate one here: https://discordapi.com/permissions.html
|
||||
|
||||
Please note that you might need the two factor authentification for\
|
||||
some permissions.
|
||||
"""
|
||||
await self.bot.db.invite_perm.set(level)
|
||||
await ctx.send("The new permissions level has been set.")
|
||||
|
||||
@commands.command()
|
||||
@commands.guild_only()
|
||||
@checks.is_owner()
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user