Add serverlock warning to [p]invite (#5898)

This commit is contained in:
Kreusada 2022-11-17 23:11:56 +00:00 committed by GitHub
parent 1fbd6d854b
commit ed4f36a529
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -62,6 +62,7 @@ from .utils.chat_formatting import (
humanize_timedelta,
inline,
pagify,
warning,
)
from .commands import CommandConverter, CogConverter
from .commands.requires import PrivilegeLevel
@ -1477,8 +1478,16 @@ class Core(commands.commands._RuleDropper, commands.Cog, CoreLogic):
**Example:**
- `[p]invite`
"""
message = await self.bot.get_invite_url()
if (admin := self.bot.get_cog("Admin")) and await admin.config.serverlocked():
message += "\n\n" + warning(
_(
"This bot is currently **serverlocked**, meaning that it is locked "
"to its current servers and will leave any server it joins."
)
)
try:
await ctx.author.send(await self.bot.get_invite_url())
await ctx.author.send(message)
await ctx.tick()
except discord.errors.Forbidden:
await ctx.send(