feat(command|help): finish help command

This commit is contained in:
Romain J 2020-01-05 01:01:06 +01:00
commit 248228408d
10 changed files with 434 additions and 205 deletions

View file

@ -65,8 +65,9 @@ class Admin(commands.Cog):
###########################################################################
@groupExtra(name='say', invoke_without_command=True, category='admin',
description=Texts('admin_help').get('_say'))
@groupExtra(name='say', invoke_without_command=True, category='text',
description=Texts('admin_help').get('_say'),
short_doc=Texts('admin_help').get('_say__short'))
async def _say(self, ctx: commands.Context, *, content: str):
if ctx.invoked_subcommand is None:
try:
@ -77,7 +78,8 @@ class Admin(commands.Cog):
await ctx.send(content)
@_say.command(name='edit',
description=Texts('admin_help').get('_say_edit'))
description=Texts('admin_help').get('_say_edit'),
short_doc=Texts('admin_help').get('_say_edit__short'))
async def _say_edit(self, ctx: commands.Context, message_id: int, *,
content: str):
try:
@ -95,7 +97,8 @@ class Admin(commands.Cog):
delete_after=5)
@_say.command(name='to',
description=Texts('admin_help').get('_say_to'))
description=Texts('admin_help').get('_say_to'),
short_doc=Texts('admin_help').get('_say_to__short'))
async def _say_to(self, ctx: commands.Context,
channel: Union[discord.TextChannel, discord.User], *,
content):
@ -108,8 +111,9 @@ class Admin(commands.Cog):
###########################################################################
@commandExtra(name='ban', category='admin',
description=Texts('admin_help').get('_ban'))
@commandExtra(name='ban', category='administration',
description=Texts('admin_help').get('_ban'),
short_doc=Texts('admin_help').get('_ban__short'))
async def _ban(self, ctx: commands.Context, user: discord.Member, *,
reason=""):
try:
@ -136,8 +140,9 @@ class Admin(commands.Cog):
###########################################################################
@commandExtra(name='kick', category='admin',
description=Texts('admin_help').get('_kick'))
@commandExtra(name='kick', category='administration',
description=Texts('admin_help').get('_kick'),
short_doc=Texts('admin_help').get('_kick__short'))
async def _kick(self, ctx: commands.Context, user: discord.Member, *,
reason=""):
try:
@ -164,8 +169,9 @@ class Admin(commands.Cog):
###########################################################################
@commandExtra(name='clear', category='admin',
description=Texts('admin_help').get('_clear'))
@commandExtra(name='clear', category='text',
description=Texts('admin_help').get('_clear'),
short_doc=Texts('admin_help').get('_clear__short'))
async def _clear(self, ctx: commands.Context, count: int):
try:
await ctx.message.delete()
@ -175,14 +181,16 @@ class Admin(commands.Cog):
###########################################################################
@groupExtra(name='react', category='admin',
description=Texts('admin_help').get('_react'))
@groupExtra(name='react', category='text',
description=Texts('admin_help').get('_react'),
short_doc=Texts('admin_help').get('_react__short'))
async def _react(self, ctx: commands.Context):
if ctx.invoked_subcommand is None:
await ctx.send_help('react')
@_react.command(name='add',
description=Texts('admin_help').get('admin._react_add'))
description=Texts('admin_help').get('_react_add'),
short_doc=Texts('admin_help').get('_react_add__short'))
async def _react_add(self, ctx: commands.Context, message_id: int, *,
emojis: str):
emojis: list = emojis.split(' ')
@ -199,7 +207,8 @@ class Admin(commands.Cog):
delete_after=5)
@_react.command(name='clear',
description=Texts('admin_help').get('_react_remove'))
description=Texts('admin_help').get('_react_remove'),
short_doc=Texts('admin_help').get('_react_remove__short'))
async def _react_remove(self, ctx: commands.Context, message_id: int):
try:
message: discord.Message = await ctx.channel.fetch_message(
@ -213,8 +222,9 @@ class Admin(commands.Cog):
###########################################################################
@groupExtra(name='delete', invoke_without_command=True,
category='admin',
description=Texts('admin_help').get('_delete'))
category='text',
description=Texts('admin_help').get('_delete'),
short_doc=Texts('admin_help').get('_delete__short'))
async def _delete(self, ctx: commands.Context, message_id: int):
try:
await ctx.message.delete()
@ -231,7 +241,8 @@ class Admin(commands.Cog):
delete_after=5)
@_delete.command(name='from', aliases=['to', 'in'],
description=Texts('admin_help').get('_delete_from'))
description=Texts('admin_help').get('_delete_from'),
short_doc=Texts('admin_help').get('_delete_from__short'))
async def _delete_from(self, ctx: commands.Context,
channel: discord.TextChannel, message_id: int):
try:
@ -259,7 +270,8 @@ class Admin(commands.Cog):
if member:
warns = self.bot.database.session \
.query(WarnModel) \
.filter(WarnModel.user_id == member.id, WarnModel.created_at > week_ago,
.filter(WarnModel.user_id == member.id,
WarnModel.created_at > week_ago,
WarnModel.server_id == ctx.guild.id) \
.order_by(WarnModel.created_at.desc())
else:
@ -287,14 +299,16 @@ class Admin(commands.Cog):
reason):
now = datetime.datetime.now()
warn = WarnModel(server_id=ctx.guild.id, user_id=member.id, reason=reason,
warn = WarnModel(server_id=ctx.guild.id, user_id=member.id,
reason=reason,
created_at=now)
self.bot.database.session.add(warn)
self.bot.database.session.commit()
@groupExtra(name='warn', aliases=['warns'], category='admin',
description=Texts('admin_help').get('_warn'))
@groupExtra(name='warn', aliases=['warns'], category='administration',
description=Texts('admin_help').get('_warn'),
short_doc=Texts('admin_help').get('_warn__short'))
async def _warn(self, ctx: commands.Context):
await ctx.trigger_typing()
if ctx.invoked_subcommand is None:
@ -307,7 +321,8 @@ class Admin(commands.Cog):
await ctx.send(embed=e)
@_warn.command(name='add', aliases=['new'],
description=Texts('admin_help').get('_warn_new'))
description=Texts('admin_help').get('_warn_new'),
short_doc=Texts('admin_help').get('_warn_new__short'))
async def _warn_new(self, ctx: commands.Context, member: discord.Member,
*, reason="N/A"):
member = await ctx.guild.fetch_member(member.id)
@ -387,7 +402,8 @@ class Admin(commands.Cog):
)
@_warn.command(name='remove', aliases=['revoke', 'del', 'delete'],
description=Texts('admin_help').get('_warn_remove'))
description=Texts('admin_help').get('_warn_remove'),
short_doc=Texts('admin_help').get('_warn_remove__short'))
async def _warn_remove(self, ctx: commands.Context, warn_id: int):
warn = self.bot.database.session \
.query(WarnModel) \
@ -400,7 +416,8 @@ class Admin(commands.Cog):
f" {Texts('admin', ctx).get('successfully removed')}")
@_warn.command(name='show', aliases=['list', 'all'],
description=Texts('admin_help').get('_warn_show'))
description=Texts('admin_help').get('_warn_show'),
short_doc=Texts('admin_help').get('_warn_show__short'))
async def _warn_show(self, ctx: commands.Context, member: discord.Member):
warns_list, warns = await self.get_warn(ctx, member)
@ -412,7 +429,8 @@ class Admin(commands.Cog):
await ctx.send(embed=e)
@_warn.command(name='edit', aliases=['change', 'modify'],
description=Texts('admin_help').get('_warn_edit'))
description=Texts('admin_help').get('_warn_edit'),
short_doc=Texts('admin_help').get('_warn_edit__short'))
async def _warn_edit(self, ctx: commands.Context, warn_id: int, *, reason):
warn = self.bot.database.session \
.query(WarnModel) \
@ -428,8 +446,9 @@ class Admin(commands.Cog):
###########################################################################
@commandExtra(name='language', aliases=['lang', 'langue', 'langage'],
category='admin',
description=Texts('admin_help').get('_language'))
category='server',
description=Texts('admin_help').get('_language'),
short_doc=Texts('admin_help').get('_language__short'))
async def _language(self, ctx: commands.Context, locale: str):
available = self.bot.database.session \
.query(LangModel.value) \
@ -450,7 +469,8 @@ class Admin(commands.Cog):
current.value = locale.lower()
self.bot.database.session.commit()
else:
new_row = LangModel(key=str(ctx.guild.id), value=locale.lower())
new_row = LangModel(key=str(ctx.guild.id),
value=locale.lower())
self.bot.database.session.add(new_row)
self.bot.database.session.commit()
@ -459,14 +479,16 @@ class Admin(commands.Cog):
###########################################################################
@groupExtra(name='prefix', aliases=['prefixes'], category='admin',
description=Texts('admin_help').get('_prefix'))
@groupExtra(name='prefix', aliases=['prefixes'], category='server',
description=Texts('admin_help').get('_prefix'),
short_doc=Texts('admin_help').get('_prefix_short'))
async def _prefix(self, ctx: commands.Context):
if ctx.invoked_subcommand is None:
await ctx.send_help('prefix')
@_prefix.command(name='add', aliases=['set', 'new'],
description=Texts('admin_help').get('_prefix_add'))
description=Texts('admin_help').get('_prefix_add'),
short_doc=Texts('admin_help').get('_prefix_add__short'))
async def _prefix_add(self, ctx: commands.Context, prefix: str):
if str(ctx.guild.id) in self.bot.prefixes:
prefixes = self.bot.prefixes.get(
@ -500,7 +522,9 @@ class Admin(commands.Cog):
)
@_prefix.command(name='remove', aliases=['drop', 'del', 'delete'],
description=Texts('admin_help').get('_prefix_remove'))
description=Texts('admin_help').get('_prefix_remove'),
short_doc=Texts('admin_help').get(
'_prefix_remove__short'))
async def _prefix_remove(self, ctx: commands.Context, prefix: str):
if str(ctx.guild.id) in self.bot.prefixes:
prefixes = self.bot.prefixes.get(
@ -529,7 +553,8 @@ class Admin(commands.Cog):
)
@_prefix.command(name='list', aliases=['show', 'all'],
description=Texts('admin_help').get('_prefix_list'))
description=Texts('admin_help').get('_prefix_list'),
short_doc=Texts('admin_help').get('_prefix_list__short'))
async def _prefix_list(self, ctx: commands.Context):
extras = ['.']
if ctx.message.guild is not None:
@ -546,10 +571,10 @@ class Admin(commands.Cog):
prefixes.extend(extras)
if len(prefixes) <= 1:
text = Texts('admin', ctx)\
text = Texts('admin', ctx) \
.get('The only prefix for this guild is :\n')
else:
text = Texts('admin', ctx)\
text = Texts('admin', ctx) \
.get('Available prefixes for this guild are :\n')
await ctx.send(text + "\n".join(prefixes))

View file

@ -4,9 +4,11 @@ import logging
import discord
from discord.ext import commands
from discord import utils
from bot import TuxBot
from utils import Texts
from utils.paginator import FieldPages
log = logging.getLogger(__name__)
@ -14,8 +16,46 @@ log = logging.getLogger(__name__)
class HelpCommand(commands.HelpCommand):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.ignore_cogs = ["Monitoring", "Help", "Logs"]
self.owner_cogs = []
self.ignore_cogs = ["Monitoring", "Help", "Jishaku"]
self.owner_cogs = ["Admin"]
def common_command_formatting(self, emb, command):
prefix = self.context.prefix if str(self.context.bot.user.id) in self.context.prefix else f"@{self.context.bot.user.name}"
emb.title = self.get_command_signature(command)
emb.description = command.description
usage = command.description + "todo: usage"
try:
usg = command.description + "todo: usage"
emb.add_field(
name=usage,
value=f"{prefix}{command.qualified_name} " + usg
)
except KeyError:
emb.add_field(
name=usage,
value=f"{prefix}{command.qualified_name}"
)
aliases = "`" + '`, `'.join(command.aliases) + "`"
if aliases == "``":
aliases = Texts(
'help', self.context
).get(
'command_help.no_aliases'
)
emb.add_field(
name=Texts(
'help', self.context
).get(
'command_help.aliases'
),
value=aliases
)
return emb
async def send_bot_help(self, mapping):
owners = self.context.bot.owners
@ -23,9 +63,10 @@ class HelpCommand(commands.HelpCommand):
f"{owner.name}#{owner.discriminator}"
for owner in owners
]
prefix = self.context.prefix if str(self.context.bot.user.id) not in self.context.prefix else f"@{self.context.bot.user.name} "
e = discord.Embed(
color=discord.colour.Color.blue(),
color=discord.Color.blue(),
description=Texts(
'help', self.context
).get(
@ -34,22 +75,28 @@ class HelpCommand(commands.HelpCommand):
', '.join(owners_name[:-1]) + ' & ' + owners_name[-1]
)
)
e.set_author(
icon_url=self.context.author.avatar_url_as(format='png'),
name=self.context.author
)
e.set_footer(
text=Texts(
'help', self.context
).get(
'main_page.footer'
).format(
prefix
)
)
cogs = ""
for extension in self.context.bot.cogs.values():
if self.context.author not in owners \
and extension.qualified_name in self.owner_cogs:
and extension.__class__.__name__ in self.owner_cogs:
continue
if self.context.author in owners \
and extension.qualified_name in self.ignore_cogs:
continue
if extension.qualified_name == "Jishaku":
if extension.__class__.__name__ in self.ignore_cogs:
continue
cogs += f"{extension.icon} **{extension.qualified_name}**\n"
e.add_field(
@ -63,6 +110,100 @@ class HelpCommand(commands.HelpCommand):
await self.context.send(embed=e)
async def send_cog_help(self, cog):
pages = {}
prefix = self.context.prefix if str(self.context.bot.user.id) in self.context.prefix else f"@{self.context.bot.user.name}"
if cog.__class__.__name__ in self.owner_cogs \
and self.context.author not in self.context.bot.owners:
return self.command_not_found(cog.qualified_name)
for cmd in cog.get_commands():
if self.context.author not in self.context.bot.owners \
and (cmd.hidden or cmd.category == "Hidden"):
continue
if cmd.category not in pages:
pages[cmd.category] = "```asciidoc\n"
pages[cmd.category] \
+= f"{cmd.name}" \
+ ' ' * int(17 - len(cmd.name)) \
+ f":: {cmd.short_doc}\n"
if isinstance(cmd, commands.Group):
for group_command in cmd.commands:
pages[cmd.category] \
+= f"{group_command.name}" \
+ ' ' * int(15 - len(group_command.name)) \
+ f":: {cmd.short_doc}\n"
for e in pages:
pages[e] += "```"
formatted = []
for name, cont in pages.items():
formatted.append((name, cont))
footer_text = Texts('help', self.context) \
.get('main_page.footer') \
.format(prefix)
pages = FieldPages(
self.context,
embed_color=discord.Color.blue(),
entries=formatted,
title=cog.qualified_name.upper(),
thumbnail=cog.big_icon,
footericon=self.context.bot.user.avatar_url,
footertext=footer_text,
per_page=1
)
await pages.paginate()
async def send_group_help(self, group):
if group.cog_name in self.ignore_cogs:
return await self.send_error_message(
self.command_not_found(group.name)
)
formatted = self.common_command_formatting(
discord.Embed(color=discord.Color.blue()),
group
)
sub_cmd_list = ""
for group_command in group.commands:
sub_cmd_list += f"└> **{group_command.name}** - {group_command.description}\n"
subcommands = Texts(
'help', self.context
).get(
'command_help.subcommands'
)
formatted.add_field(name=subcommands, value=sub_cmd_list, inline=False)
await self.context.send(embed=formatted)
async def send_command_help(self, command):
if isinstance(command, commands.Group):
return await self.send_group_help(command)
if command.cog_name in self.ignore_cogs:
return await self.send_error_message(
self.command_not_found(command.name))
formatted = self.common_command_formatting(
discord.Embed(color=discord.Color.blue()),
command
)
await self.context.send(embed=formatted)
def command_not_found(self, command):
return Texts(
'help', self.context
).get(
'main_page.not_found'
).format(
command
)
class Help(commands.Cog):
def __init__(self, bot: TuxBot):

View file

@ -1,7 +1,7 @@
"""
Based on https://github.com/Rapptz/RoboDanny/blob/3d94e89ef27f702a5f57f432a9131bdfb60bb3ec/cogs/stats.py
Rewrite by Romain J.
Adapted by Romain J.
"""
@ -52,6 +52,9 @@ class Logs(commands.Cog):
self._resumes = []
self._identifies = defaultdict(list)
self.icon = ":newspaper:"
self.big_icon = "https://emojipedia-us.s3.dualstack.us-west-1.amazonaws.com/thumbs/120/twitter/233/newspaper_1f4f0.png"
def _clear_gateway_data(self):
one_week_ago = datetime.datetime.utcnow() - datetime.timedelta(days=7)
to_remove = [
@ -240,8 +243,9 @@ class Logs(commands.Cog):
msg = f'{emoji} `[{dt:%Y-%m-%d %H:%M:%S}] {record.message}`'
await self.webhook.send(msg)
@commandExtra(name='commandstats', hidden=True, category='logs',
description=Texts('logs_help').get('_commandstats'))
@commandExtra(name='commandstats', hidden=True, category='misc',
description=Texts('logs_help').get('_commandstats'),
short_doc=Texts('logs_help').get('_commandstats__short'))
@commands.is_owner()
async def _commandstats(self, ctx, limit=20):
counter = self.bot.command_stats
@ -256,8 +260,9 @@ class Logs(commands.Cog):
await ctx.send(f'```\n{output}\n```')
@commandExtra(name='socketstats', hidden=True, category='logs',
description=Texts('logs_help').get('_socketstats'))
@commandExtra(name='socketstats', hidden=True, category='misc',
description=Texts('logs_help').get('_socketstats'),
short_doc=Texts('logs_help').get('_socketstats__short'))
@commands.is_owner()
async def _socketstats(self, ctx):
delta = datetime.datetime.utcnow() - self.bot.uptime
@ -267,8 +272,9 @@ class Logs(commands.Cog):
await ctx.send(
f'{total} socket events observed ({cpm:.2f}/minute):\n{self.bot.socket_stats}')
@commandExtra(name='uptime', category='logs',
description=Texts('logs_help').get('_uptime'))
@commandExtra(name='uptime', category='misc',
description=Texts('logs_help').get('_uptime'),
short_doc=Texts('logs_help').get('_uptime__short'))
async def _uptime(self, ctx):
"""Tells you how long the bot has been up for."""
uptime = humanize.naturaltime(

View file

@ -204,15 +204,17 @@ class Polls(commands.Cog):
poll.content = json.dumps(content)
self.bot.database.session.commit()
@groupExtra(name='sondage', aliases=['poll'],
@groupExtra(name='poll', aliases=['sondage'],
category='poll',
description=Texts('poll_help').get('_poll'))
description=Texts('poll_help').get('_poll'),
short_doc=Texts('poll_help').get('_poll__short'))
async def _poll(self, ctx: commands.Context):
if ctx.invoked_subcommand is None:
await ctx.send_help('sondage')
@_poll.group(name='create', aliases=['new', 'nouveau'],
description=Texts('poll_help').get('_poll_create'))
description=Texts('poll_help').get('_poll_create'),
short_doc=Texts('poll_help').get('_poll_create__short'))
async def _poll_create(self, ctx: commands.Context, *, poll: str):
is_anonymous = '--anonyme' in poll
poll = poll.replace('--anonyme', '')

View file

@ -36,10 +36,41 @@ class Useful(commands.Cog):
return os.popen(cmd).read().strip()
@staticmethod
def fetch_info():
total_lines = 0
total_python_lines = 0
file_amount = 0
python_file_amount = 0
ENV = "env"
for path, _, files in os.walk("."):
for name in files:
file_dir = str(pathlib.PurePath(path, name))
if (
not name.endswith(".py")
and not name.endswith(".po")
and not name.endswith(".json")
) or ENV in file_dir:
continue
file_amount += 1
python_file_amount += 1 if name.endswith(".py") else 0
with open(file_dir, "r", encoding="utf-8") as file:
for line in file:
if not line.strip().startswith("#") \
or not line.strip():
total_lines += 1
total_python_lines += 1 if name.endswith(".py") \
else 0
return (file_amount, total_lines), (
python_file_amount, total_python_lines)
###########################################################################
@commandExtra(name='iplocalise', category='useful',
description=Texts('useful_help').get('_iplocalise'))
@commandExtra(name='iplocalise', category='network',
description=Texts('useful_help').get('_iplocalise'),
short_doc=Texts('useful_help').get('_iplocalise__short'))
async def _iplocalise(self, ctx: commands.Context, addr, ip_type=''):
addr = re.sub(r'http(s?)://', '', addr)
addr = addr[:-1] if addr.endswith('/') else addr
@ -103,8 +134,9 @@ class Useful(commands.Cog):
###########################################################################
@commandExtra(name='getheaders', category='useful',
description=Texts('useful_help').get('_getheaders'))
@commandExtra(name='getheaders', category='network',
description=Texts('useful_help').get('_getheaders'),
short_doc=Texts('useful_help').get('_getheaders__short'))
async def _getheaders(self, ctx: commands.Context, addr: str):
if (addr.startswith('http') or addr.startswith('ftp')) is not True:
addr = f"http://{addr}"
@ -127,7 +159,7 @@ class Useful(commands.Cog):
e.add_field(name=key, value=value, inline=True)
await ctx.send(embed=e)
except aiohttp.client_exceptions.ClientError:
except aiohttp.ClientError:
await ctx.send(
f"{Texts('useful', ctx).get('Cannot connect to host')} {addr}"
)
@ -135,8 +167,9 @@ class Useful(commands.Cog):
###########################################################################
@commandExtra(name='git', aliases=['sources', 'source', 'github'],
category='useful',
description=Texts('useful_help').get('_git'))
category='misc',
description=Texts('useful_help').get('_git'),
short_doc=Texts('useful_help').get('_git__short'))
async def _git(self, ctx):
e = discord.Embed(
title=Texts('useful', ctx).get('git repo'),
@ -151,8 +184,9 @@ class Useful(commands.Cog):
###########################################################################
@commandExtra(name='quote', category='useful',
description=Texts('useful_help').get('_quote'))
@commandExtra(name='quote', category='misc',
description=Texts('useful_help').get('_quote'),
short_doc=Texts('useful_help').get('_quote__short'))
async def _quote(self, ctx, message_id: discord.Message):
e = discord.Embed(
colour=message_id.author.colour,
@ -174,8 +208,9 @@ class Useful(commands.Cog):
###########################################################################
@commandExtra(name='ping', category='useful',
description=Texts('useful_help').get('_ping'))
@commandExtra(name='ping', category='network',
description=Texts('useful_help').get('_ping'),
short_doc=Texts('useful_help').get('_ping__short'))
async def _ping(self, ctx: commands.Context):
start = time.perf_counter()
await ctx.trigger_typing()
@ -193,37 +228,9 @@ class Useful(commands.Cog):
###########################################################################
@staticmethod
def fetch_info():
total_lines = 0
total_python_lines = 0
file_amount = 0
python_file_amount = 0
ENV = "env"
for path, _, files in os.walk("."):
for name in files:
file_dir = str(pathlib.PurePath(path, name))
if (
not name.endswith(".py")
and not name.endswith(".po")
and not name.endswith(".json")
) or ENV in file_dir:
continue
file_amount += 1
python_file_amount += 1 if name.endswith(".py") else 0
with open(file_dir, "r", encoding="utf-8") as file:
for line in file:
if not line.strip().startswith("#") \
or not line.strip():
total_lines += 1
total_python_lines += 1 if name.endswith(".py") \
else 0
return (file_amount, total_lines), (python_file_amount, total_python_lines)
@commandExtra(name='info', aliases=['about'], category='useful',
description=Texts('useful_help').get('_info'))
@commandExtra(name='info', aliases=['about'], category='misc',
description=Texts('useful_help').get('_info'),
short_doc=Texts('useful_help').get('_info__short'))
async def _info(self, ctx: commands.Context):
proc = psutil.Process()
total, python = self.fetch_info()
@ -306,8 +313,9 @@ class Useful(commands.Cog):
###########################################################################
@commandExtra(name='credits', aliases=['contributors', 'authors'],
category='useful',
description=Texts('useful_help').get('_credits'))
category='misc',
description=Texts('useful_help').get('_credits'),
short_doc=Texts('useful_help').get('_credits__short'))
async def _credits(self, ctx: commands.Context):
e = discord.Embed(
title=Texts('useful', ctx).get('Contributors'),

View file

@ -19,14 +19,16 @@ class User(commands.Cog):
###########################################################################
@groupExtra(name='alias', aliases=['aliases'], category='user',
description=Texts('user_help').get('user._alias'))
@groupExtra(name='alias', aliases=['aliases'], category='alias',
description=Texts('user_help').get('_alias'),
short_doc=Texts('user_help').get('_alias__short'))
async def _alias(self, ctx: commands.Context):
if ctx.invoked_subcommand is None:
await ctx.send_help('alias')
@_alias.command(name='add', aliases=['set', 'new'],
description=Texts('user_help').get('_alias_add'))
description=Texts('user_help').get('_alias_add'),
short_doc=Texts('user_help').get('_alias_add__short'))
async def _alias_add(self, ctx: commands.Context, *, user_alias: str):
is_global = False
if '--global' in user_alias:
@ -54,12 +56,14 @@ class User(commands.Cog):
self.bot.database.session.commit()
@_alias.command(name='remove', aliases=['drop', 'del', 'delete'],
description=Texts('user_help').get('_alias_remove'))
description=Texts('user_help').get('_alias_remove'),
short_doc=Texts('user_help').get('_alias_remove__short'))
async def _alias_remove(self, ctx: commands.Context, prefix: str):
...
@_alias.command(name='list', aliases=['show', 'all'],
description=Texts('user_help').get('_alias_list'))
description=Texts('user_help').get('_alias_list'),
short_doc=Texts('user_help').get('_alias_list__short'))
async def _alias_list(self, ctx: commands.Context):
...