Skip to content

Commit

Permalink
Allow [p]info customization (#2417)
Browse files Browse the repository at this point in the history
* Allow [p]info customization

* Style

* Naming
  • Loading branch information
Twentysix26 authored and Kowlin committed Feb 8, 2019
1 parent e88c82e commit b350ac3
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
1 change: 1 addition & 0 deletions redbot/core/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -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="",
Expand Down
24 changes: 24 additions & 0 deletions redbot/core/core_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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(
Expand Down Expand Up @@ -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):
Expand Down

0 comments on commit b350ac3

Please sign in to comment.