mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-05-15 18:29:52 +00:00
[commands] Fix @everyone elevation in the default help command.
This commit is contained in:
parent
1228159f30
commit
bde266bbb9
@ -30,6 +30,7 @@ import inspect
|
|||||||
import importlib
|
import importlib
|
||||||
import sys
|
import sys
|
||||||
import traceback
|
import traceback
|
||||||
|
import re
|
||||||
|
|
||||||
from .core import GroupMixin, Command, command
|
from .core import GroupMixin, Command, command
|
||||||
from .view import StringView
|
from .view import StringView
|
||||||
@ -80,18 +81,28 @@ def when_mentioned_or(*prefixes):
|
|||||||
|
|
||||||
return inner
|
return inner
|
||||||
|
|
||||||
|
_mentions_transforms = {
|
||||||
|
'@everyone': '@\u200beveryone',
|
||||||
|
'@here': '@\u200bhere'
|
||||||
|
}
|
||||||
|
|
||||||
|
_mention_pattern = re.compile('|'.join(_mentions_transforms.keys()))
|
||||||
|
|
||||||
@asyncio.coroutine
|
@asyncio.coroutine
|
||||||
def _default_help_command(ctx, *commands : str):
|
def _default_help_command(ctx, *commands : str):
|
||||||
"""Shows this message."""
|
"""Shows this message."""
|
||||||
bot = ctx.bot
|
bot = ctx.bot
|
||||||
destination = ctx.message.author if bot.pm_help else ctx.message.channel
|
destination = ctx.message.author if bot.pm_help else ctx.message.channel
|
||||||
|
|
||||||
|
def repl(obj):
|
||||||
|
return _mentions_transforms.get(obj.group(0), '')
|
||||||
|
|
||||||
# help by itself just lists our own commands.
|
# help by itself just lists our own commands.
|
||||||
if len(commands) == 0:
|
if len(commands) == 0:
|
||||||
pages = bot.formatter.format_help_for(ctx, bot)
|
pages = bot.formatter.format_help_for(ctx, bot)
|
||||||
elif len(commands) == 1:
|
elif len(commands) == 1:
|
||||||
# try to see if it is a cog name
|
# try to see if it is a cog name
|
||||||
name = commands[0]
|
name = _mention_pattern.sub(repl, commands[0])
|
||||||
command = None
|
command = None
|
||||||
if name in bot.cogs:
|
if name in bot.cogs:
|
||||||
command = bot.cogs[name]
|
command = bot.cogs[name]
|
||||||
@ -103,7 +114,7 @@ def _default_help_command(ctx, *commands : str):
|
|||||||
|
|
||||||
pages = bot.formatter.format_help_for(ctx, command)
|
pages = bot.formatter.format_help_for(ctx, command)
|
||||||
else:
|
else:
|
||||||
name = commands[0]
|
name = _mention_pattern.sub(repl, commands[0])
|
||||||
command = bot.commands.get(name)
|
command = bot.commands.get(name)
|
||||||
if command is None:
|
if command is None:
|
||||||
yield from bot.send_message(destination, bot.command_not_found.format(name))
|
yield from bot.send_message(destination, bot.command_not_found.format(name))
|
||||||
@ -111,6 +122,7 @@ def _default_help_command(ctx, *commands : str):
|
|||||||
|
|
||||||
for key in commands[1:]:
|
for key in commands[1:]:
|
||||||
try:
|
try:
|
||||||
|
key = _mention_pattern.sub(repl, key)
|
||||||
command = command.commands.get(key)
|
command = command.commands.get(key)
|
||||||
if command is None:
|
if command is None:
|
||||||
yield from bot.send_message(destination, bot.command_not_found.format(key))
|
yield from bot.send_message(destination, bot.command_not_found.format(key))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user