|
17 | 17 | from discord import Embed, Color, Activity, Role
|
18 | 18 | from discord.enums import ActivityType, Status
|
19 | 19 | from discord.ext import commands
|
20 |
| -from discord.utils import escape_markdown |
| 20 | +from discord.utils import escape_markdown, escape_mentions |
21 | 21 |
|
22 | 22 | from aiohttp import ClientResponseError
|
23 | 23 | from pkg_resources import parse_version
|
@@ -180,20 +180,48 @@ async def send_group_help(self, group):
|
180 | 180 |
|
181 | 181 | await self.get_destination().send(embed=embed)
|
182 | 182 |
|
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)) |
185 | 213 |
|
186 | 214 | embed = Embed(color=Color.red())
|
187 | 215 | embed.set_footer(
|
188 |
| - text=f'Command/Category "{self.context.kwargs.get("command")}" not found.' |
| 216 | + text=f'Command/Category "{command}" not found.' |
189 | 217 | )
|
190 | 218 |
|
191 | 219 | choices = set()
|
192 | 220 |
|
193 | 221 | for name, cmd in self.context.bot.all_commands.items():
|
194 | 222 | if not cmd.hidden:
|
195 | 223 | choices.add(name)
|
196 |
| - command = self.context.kwargs.get("command") |
| 224 | + |
197 | 225 | closest = get_close_matches(command, choices)
|
198 | 226 | if closest:
|
199 | 227 | embed.add_field(
|
@@ -870,7 +898,7 @@ async def alias(self, ctx, *, name: str.lower = None):
|
870 | 898 | else:
|
871 | 899 | embed = Embed(
|
872 | 900 | color=self.bot.main_color,
|
873 |
| - description=f"`{name}` points to the following steps:", |
| 901 | + description=f"**`{name}` points to the following steps:**", |
874 | 902 | )
|
875 | 903 | for i, val in enumerate(values, start=1):
|
876 | 904 | embed.description += f"\n{i}: {escape_markdown(val)}"
|
|
0 commit comments