Skip to content

Commit 1f8d2d0

Browse files
committed
Snippet/alias help msg
1 parent d220937 commit 1f8d2d0

File tree

2 files changed

+36
-7
lines changed

2 files changed

+36
-7
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ however, insignificant breaking changes does not guarantee a major version bump,
2222
- For users having trouble with pipenv or any other reason.
2323
- Multi-step alias, see `?help alias add`. Public beta testing, might be unstable.
2424
- Misc commands without cogs are now displayed in `?help`.
25+
- `?help` works for alias and snippets.
2526

2627
### Changes
2728

@@ -39,7 +40,7 @@ however, insignificant breaking changes does not guarantee a major version bump,
3940

4041
- `?notify` no longer carries over to the next thread.
4142
- `discord.NotFound` errors for `on_raw_reaction_add`.
42-
- `mod_typing` ~~and `user_typing`~~ (`user_typing` is by-design to show now) will no longer show when user is blocked.
43+
- `mod_typing` ~~and `user_typing`~~ (`user_typing` is now by-design to show) will no longer show when user is blocked.
4344
- Better `?block` usage message.
4445
- Resolves errors when message was sent by mods after thread is closed somehow.
4546
- Recipient join/leave server messages are limited to only the guild set by `GUILD_ID`.

cogs/utility.py

Lines changed: 34 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
from discord import Embed, Color, Activity, Role
1818
from discord.enums import ActivityType, Status
1919
from discord.ext import commands
20-
from discord.utils import escape_markdown
20+
from discord.utils import escape_markdown, escape_mentions
2121

2222
from aiohttp import ClientResponseError
2323
from pkg_resources import parse_version
@@ -180,20 +180,48 @@ async def send_group_help(self, group):
180180

181181
await self.get_destination().send(embed=embed)
182182

183-
async def send_error_message(self, msg): # pylint: disable=W0221
184-
logger.warning("CommandNotFound: %s", str(msg))
183+
async def send_error_message(self, error):
184+
command = self.context.kwargs.get("command")
185+
val = self.context.bot.snippets.get(command)
186+
if val is not None:
187+
return await self.get_destination().send(escape_mentions(f'**`{command}` is a snippet, '
188+
f'content:**\n\n{val}'))
189+
190+
val = self.context.bot.aliases.get(command)
191+
if val is not None:
192+
values = parse_alias(val)
193+
194+
if len(values) == 1:
195+
embed = Embed(
196+
title=f"{command} is an alias.",
197+
color=self.context.bot.main_color,
198+
description=f"`{command}` points to `{escape_markdown(values[0])}`.",
199+
)
200+
else:
201+
embed = Embed(
202+
title=f"{command} is an alias.",
203+
color=self.context.bot.main_color,
204+
description=f"**`{command}` points to the following steps:**",
205+
)
206+
for i, val in enumerate(values, start=1):
207+
embed.description += f"\n{i}: {escape_markdown(val)}"
208+
embed.set_footer(text=f'Type "{self.clean_prefix}{self.command_attrs["name"]} alias" for more '
209+
'details on aliases.')
210+
return await self.get_destination().send(embed=embed)
211+
212+
logger.warning("CommandNotFound: %s", str(error))
185213

186214
embed = Embed(color=Color.red())
187215
embed.set_footer(
188-
text=f'Command/Category "{self.context.kwargs.get("command")}" not found.'
216+
text=f'Command/Category "{command}" not found.'
189217
)
190218

191219
choices = set()
192220

193221
for name, cmd in self.context.bot.all_commands.items():
194222
if not cmd.hidden:
195223
choices.add(name)
196-
command = self.context.kwargs.get("command")
224+
197225
closest = get_close_matches(command, choices)
198226
if closest:
199227
embed.add_field(
@@ -870,7 +898,7 @@ async def alias(self, ctx, *, name: str.lower = None):
870898
else:
871899
embed = Embed(
872900
color=self.bot.main_color,
873-
description=f"`{name}` points to the following steps:",
901+
description=f"**`{name}` points to the following steps:**",
874902
)
875903
for i, val in enumerate(values, start=1):
876904
embed.description += f"\n{i}: {escape_markdown(val)}"

0 commit comments

Comments
 (0)