From b350ac38dc178ad824bd40db7293ad9d92188a12 Mon Sep 17 00:00:00 2001 From: Twentysix Date: Fri, 8 Feb 2019 02:38:26 +0100 Subject: [PATCH] Allow [p]info customization (#2417) * Allow [p]info customization * Style * Naming --- redbot/core/bot.py | 1 + redbot/core/core_commands.py | 24 ++++++++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/redbot/core/bot.py b/redbot/core/bot.py index 4f5de7beea6..59a4f8ab678 100644 --- a/redbot/core/bot.py +++ b/redbot/core/bot.py @@ -52,6 +52,7 @@ def __init__(self, *args, cli_flags=None, bot_dir: Path = Path.cwd(), **kwargs): embeds=True, color=15158332, fuzzy=False, + custom_info=None, help__page_char_limit=1000, help__max_pages_in_guild=2, help__tagline="", diff --git a/redbot/core/core_commands.py b/redbot/core/core_commands.py index 9f531000100..51ac9296932 100644 --- a/redbot/core/core_commands.py +++ b/redbot/core/core_commands.py @@ -295,6 +295,7 @@ async def info(self, ctx: commands.Context): red_version = "[{}]({})".format(__version__, red_pypi) app_info = await self.bot.application_info() owner = app_info.owner + custom_info = await self.bot.db.custom_info() async with aiohttp.ClientSession() as session: async with session.get("{}/json".format(red_pypi)) as r: @@ -318,6 +319,8 @@ async def info(self, ctx: commands.Context): embed.add_field( name="Outdated", value="Yes, {} is available".format(data["info"]["version"]) ) + if custom_info: + embed.add_field(name="About this instance", value=custom_info, inline=False) embed.add_field(name="About Red", value=about, inline=False) embed.set_footer( @@ -1029,6 +1032,27 @@ async def sentry(self, ctx: commands.Context, on_or_off: bool): ctx.bot.disable_sentry() await ctx.send(_("Done. Sentry logging is now disabled.")) + @_set.command() + @checks.is_owner() + async def custominfo(self, ctx: commands.Context, *, text: str = None): + """Customizes a section of [p]info + + The maximum amount of allowed characters is 1024. + Supports markdown, links and "mentions". + Link example: + `[My link](https://example.com)` + """ + if not text: + await ctx.bot.db.custom_info.clear() + await ctx.send(_("The custom text has been cleared.")) + return + if len(text) <= 1024: + await ctx.bot.db.custom_info.set(text) + await ctx.send(_("The custom text has been set.")) + await ctx.invoke(self.info) + else: + await ctx.bot.send(_("Characters must be fewer than 1024.")) + @commands.group() @checks.is_owner() async def helpset(self, ctx: commands.Context):