[Core] Add a text only version to [p]info (#3907)

* ...

* Finish implementation

* some people think an embedless world brings joy ... I agree to disagree.
This commit is contained in:
Draper 2020-06-11 14:07:27 +01:00 committed by GitHub
parent fd8ff7d7cf
commit b1d394eac5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -310,6 +310,7 @@ class Core(commands.Cog, CoreLogic):
@commands.command()
async def info(self, ctx: commands.Context):
"""Shows info about Red"""
embed_links = await ctx.embed_requested()
author_repo = "https://github.com/Twentysix26"
org_repo = "https://github.com/Cog-Creators"
red_repo = org_repo + "/Red-DiscordBot"
@ -320,9 +321,7 @@ class Core(commands.Cog, CoreLogic):
python_url = "https://www.python.org/"
since = datetime.datetime(2016, 1, 2, 0, 0)
days_since = (datetime.datetime.utcnow() - since).days
dpy_version = "[{}]({})".format(discord.__version__, dpy_repo)
python_version = "[{}.{}.{}]({})".format(*sys.version_info[:3], python_url)
red_version = "[{}]({})".format(__version__, red_pypi)
app_info = await self.bot.application_info()
if app_info.team:
owner = app_info.team.name
@ -338,39 +337,105 @@ class Core(commands.Cog, CoreLogic):
outdated = None
else:
outdated = VersionInfo.from_str(data["info"]["version"]) > red_version_info
about = _(
"This bot is an instance of [Red, an open source Discord bot]({}) "
"created by [Twentysix]({}) and [improved by many]({}).\n\n"
"Red is backed by a passionate community who contributes and "
"creates content for everyone to enjoy. [Join us today]({}) "
"and help us improve!\n\n"
"(c) Cog Creators"
).format(red_repo, author_repo, org_repo, support_server_url)
embed = discord.Embed(color=(await ctx.embed_colour()))
embed.add_field(name=_("Instance owned by"), value=str(owner))
embed.add_field(name="Python", value=python_version)
embed.add_field(name="discord.py", value=dpy_version)
embed.add_field(name=_("Red version"), value=red_version)
if outdated in (True, None):
if outdated is True:
outdated_value = _("Yes, {version} is available.").format(
version=data["info"]["version"]
)
else:
outdated_value = _("Checking for updates failed.")
embed.add_field(name=_("Outdated"), value=outdated_value)
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)
if embed_links:
dpy_version = "[{}]({})".format(discord.__version__, dpy_repo)
python_version = "[{}.{}.{}]({})".format(*sys.version_info[:3], python_url)
red_version = "[{}]({})".format(__version__, red_pypi)
embed.set_footer(
text=_("Bringing joy since 02 Jan 2016 (over {} days ago!)").format(days_since)
)
try:
about = _(
"This bot is an instance of [Red, an open source Discord bot]({}) "
"created by [Twentysix]({}) and [improved by many]({}).\n\n"
"Red is backed by a passionate community who contributes and "
"creates content for everyone to enjoy. [Join us today]({}) "
"and help us improve!\n\n"
"(c) Cog Creators"
).format(red_repo, author_repo, org_repo, support_server_url)
embed = discord.Embed(color=(await ctx.embed_colour()))
embed.add_field(name=_("Instance owned by"), value=str(owner))
embed.add_field(name="Python", value=python_version)
embed.add_field(name="discord.py", value=dpy_version)
embed.add_field(name=_("Red version"), value=red_version)
if outdated in (True, None):
if outdated is True:
outdated_value = _("Yes, {version} is available.").format(
version=data["info"]["version"]
)
else:
outdated_value = _("Checking for updates failed.")
embed.add_field(name=_("Outdated"), value=outdated_value)
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(
text=_("Bringing joy since 02 Jan 2016 (over {} days ago!)").format(days_since)
)
await ctx.send(embed=embed)
except discord.HTTPException:
await ctx.send(_("I need the `Embed links` permission to send this"))
else:
python_version = "{}.{}.{}".format(*sys.version_info[:3])
dpy_version = "{}".format(discord.__version__,)
red_version = "{}".format(__version__)
about = _(
"This bot is an instance of Red, an open source Discord bot (1) "
"created by Twentysix (2) and improved by many (3).\n\n"
"Red is backed by a passionate community who contributes and "
"creates content for everyone to enjoy. Join us today (4) "
"and help us improve!\n\n"
"(c) Cog Creators"
)
about = box(about)
extras = _(
"Instance owned by: [{owner}]\n"
"Python: [{python_version}] (5)\n"
"discord.py: [{dpy_version}] (6)\n"
"Red version: [{red_version}] (7)\n"
).format(
owner=owner,
python_version=python_version,
dpy_version=dpy_version,
red_version=red_version,
)
if outdated in (True, None):
if outdated is True:
outdated_value = _("Yes, {version} is available.").format(
version=data["info"]["version"]
)
else:
outdated_value = _("Checking for updates failed.")
extras += _("Outdated: [{state}]\n").format(state=outdated_value)
red = (
_("**About Red**\n")
+ about
+ "\n"
+ box(extras, lang="ini")
+ "\n"
+ _("Bringing joy since 02 Jan 2016 (over {} days ago!)").format(days_since)
+ "\n\n"
)
await ctx.send(red)
if custom_info:
custom_info = _("**About this instance**\n") + custom_info + "\n\n"
await ctx.send(custom_info)
refs = _(
"**References**\n"
"1. <{}>\n"
"2. <{}>\n"
"3. <{}>\n"
"4. <{}>\n"
"5. <{}>\n"
"6. <{}>\n"
"7. <{}>\n"
).format(
red_repo, author_repo, org_repo, support_server_url, python_url, dpy_repo, red_pypi
)
await ctx.send(refs)
@commands.command()
async def uptime(self, ctx: commands.Context):