License info command (#3090)

* Adds a licenseinfo command

* good enough for now

* changelog

* *sigh* Fine, have it your way Draper

* thanks Flame
This commit is contained in:
Michael H
2019-11-09 14:06:07 -05:00
committed by GitHub
parent 418f957332
commit 6852b7a1d1
5 changed files with 78 additions and 4 deletions

View File

@@ -699,3 +699,29 @@ def get_command_disabler(guild: discord.Guild) -> Callable[["Context"], Awaitabl
__command_disablers[guild] = disabler
return disabler
# This is intentionally left out of `__all__` as it is not intended for general use
class _AlwaysAvailableCommand(Command):
"""
This should be used only for informational commands
which should not be disabled or removed
These commands cannot belong to a cog.
These commands do not respect most forms of checks, and
should only be used with that in mind.
This particular class is not supported for 3rd party use
"""
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
if self.cog is not None:
raise TypeError("This command may not be added to a cog")
async def can_run(self, ctx, *args, **kwargs) -> bool:
return not ctx.author.bot
async def _verify_checks(self, ctx) -> bool:
return not ctx.author.bot

View File

@@ -1136,7 +1136,7 @@ class Core(commands.Cog, CoreLogic):
@checks.is_owner()
async def api(self, ctx: commands.Context, service: str, *, tokens: TokenConverter):
"""Set various external API tokens.
This setting will be asked for by some 3rd party cogs and some core cogs.
To add the keys provide the service name and the tokens as a comma separated
@@ -1162,7 +1162,7 @@ class Core(commands.Cog, CoreLogic):
Allows the help command to be sent as a paginated menu instead of seperate
messages.
This defaults to False.
This defaults to False.
Using this without a setting will toggle.
"""
if use_menus is None:
@@ -1907,6 +1907,12 @@ class Core(commands.Cog, CoreLogic):
)
return
if isinstance(command_obj, commands.commands._AlwaysAvailableCommand):
await ctx.send(
_("This command is designated as being always available and cannot be disabled.")
)
return
async with ctx.bot._config.disabled_commands() as disabled_commands:
if command not in disabled_commands:
disabled_commands.append(command_obj.qualified_name)
@@ -1935,6 +1941,12 @@ class Core(commands.Cog, CoreLogic):
)
return
if isinstance(command_obj, commands.commands._AlwaysAvailableCommand):
await ctx.send(
_("This command is designated as being always available and cannot be disabled.")
)
return
if command_obj.requires.privilege_level > await PrivilegeLevel.from_ctx(ctx):
await ctx.send(_("You are not allowed to disable that command."))
return
@@ -2215,3 +2227,21 @@ class Core(commands.Cog, CoreLogic):
async def rpc_reload(self, request):
await self.rpc_unload(request)
await self.rpc_load(request)
# Removing this command from forks is a violation of the GPLv3 under which it is licensed.
# Otherwise interfering with the ability for this command to be accessible is also a violation.
@commands.command(cls=commands.commands._AlwaysAvailableCommand, name="licenseinfo", i18n=_)
async def license_info_command(ctx):
"""
Get info about Red's licenses
"""
message = (
"This bot is an instance of Red-DiscordBot (hereafter refered to as Red)\n"
"Red is a free and open source application made available to the public and "
"licensed under the GNU GPLv3. The full text of this license is available to you at "
"<https://github.com/Cog-Creators/Red-DiscordBot/blob/V3/develop/LICENSE>"
)
await ctx.send(message)
# We need a link which contains a thank you to other projects which we use at some point.