Allow [p]info customization (#2417)

* Allow [p]info customization

* Style

* Naming
This commit is contained in:
Twentysix 2019-02-08 02:38:26 +01:00 committed by Kowlin
parent e88c82e7e0
commit b350ac38dc
2 changed files with 25 additions and 0 deletions

View File

@ -52,6 +52,7 @@ class RedBase(commands.GroupMixin, commands.bot.BotBase, RPCMixin):
embeds=True, embeds=True,
color=15158332, color=15158332,
fuzzy=False, fuzzy=False,
custom_info=None,
help__page_char_limit=1000, help__page_char_limit=1000,
help__max_pages_in_guild=2, help__max_pages_in_guild=2,
help__tagline="", help__tagline="",

View File

@ -295,6 +295,7 @@ class Core(commands.Cog, CoreLogic):
red_version = "[{}]({})".format(__version__, red_pypi) red_version = "[{}]({})".format(__version__, red_pypi)
app_info = await self.bot.application_info() app_info = await self.bot.application_info()
owner = app_info.owner owner = app_info.owner
custom_info = await self.bot.db.custom_info()
async with aiohttp.ClientSession() as session: async with aiohttp.ClientSession() as session:
async with session.get("{}/json".format(red_pypi)) as r: async with session.get("{}/json".format(red_pypi)) as r:
@ -318,6 +319,8 @@ class Core(commands.Cog, CoreLogic):
embed.add_field( embed.add_field(
name="Outdated", value="Yes, {} is available".format(data["info"]["version"]) 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.add_field(name="About Red", value=about, inline=False)
embed.set_footer( embed.set_footer(
@ -1029,6 +1032,27 @@ class Core(commands.Cog, CoreLogic):
ctx.bot.disable_sentry() ctx.bot.disable_sentry()
await ctx.send(_("Done. Sentry logging is now disabled.")) 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() @commands.group()
@checks.is_owner() @checks.is_owner()
async def helpset(self, ctx: commands.Context): async def helpset(self, ctx: commands.Context):