diff --git a/discord/__init__.py b/discord/__init__.py index 589fdd3a..ca9dcd77 100644 --- a/discord/__init__.py +++ b/discord/__init__.py @@ -15,7 +15,7 @@ __title__ = 'discord' __author__ = 'Rapptz' __license__ = 'MIT' __copyright__ = 'Copyright 2015-2020 Rapptz' -__version__ = '1.6.0.6' +__version__ = '1.6.0.7' __path__ = __import__('pkgutil').extend_path(__path__, __name__) diff --git a/discord/ext/commands/bot.py b/discord/ext/commands/bot.py index f4a3918d..0d817074 100644 --- a/discord/ext/commands/bot.py +++ b/discord/ext/commands/bot.py @@ -28,6 +28,7 @@ import asyncio import collections import inspect import importlib.util +import itertools import sys import traceback import types @@ -94,9 +95,10 @@ class _DefaultRepr: _default = _DefaultRepr() class BotBase(GroupMixin): - def __init__(self, command_prefix, help_command=_default, description=None, **options): + def __init__(self, command_prefix, case_insensitive_prefix=False, help_command=_default, description=None, **options): super().__init__(**options) self.command_prefix = command_prefix + self.case_insensitive_prefix = case_insensitive_prefix self.extra_events = {} self.__cogs = {} self.__extensions = {} @@ -828,7 +830,13 @@ class BotBase(GroupMixin): if not isinstance(ret, str): try: - ret = list(ret) + if self.case_insensitive_prefix: + temp = [] + for pre in ret: + temp += list(map(''.join, itertools.product(*((c.upper(), c.lower()) for c in ret)))) + ret = temp + else: + ret = list(ret) except TypeError: # It's possible that a generator raised this exception. Don't # replace it with our own error if that's the case. @@ -841,6 +849,8 @@ class BotBase(GroupMixin): if not ret: raise ValueError("Iterable command_prefix must contain at least one prefix") + if self.case_insensitive_prefix: + return list(map(''.join, itertools.product(*((c.upper(), c.lower()) for c in ret)))) return ret async def get_context(self, message, *, cls=Context): @@ -1012,6 +1022,10 @@ class Bot(BotBase, discord.Client): matches messages starting with ``!?``. This is especially important when passing an empty string, it should always be last as no prefix after it will be matched. + case_insensitive_prefix: :class:`bool` + Wheter the provided command_prefix should be case insensitive or not + + .. versionadded:: 1.6.0.7 case_insensitive: :class:`bool` Whether the commands should be case insensitive. Defaults to ``False``. This attribute does not carry over to groups. You must set it to every group if diff --git a/docs/custom_features.rst b/docs/custom_features.rst index 484146b1..ac63e54d 100644 --- a/docs/custom_features.rst +++ b/docs/custom_features.rst @@ -27,4 +27,6 @@ Here are the custom features listed that have been added to enhanced-dpy. You ca - Added ``Guild.try_member`` - Added ``Context.clean_prefix`` - Added ``Color.nitro_booster`` -- Added ``Permissions.admin`` as alias to ``Permissions.administrator`` \ No newline at end of file +- Added ``Permissions.admin`` as alias to ``Permissions.administrator`` +- Added ``Cog.aliases`` +- Added ``Bot.case_insensitive_prefix`` \ No newline at end of file diff --git a/docs/whats_new.rst b/docs/whats_new.rst index cfc86070..acf82752 100644 --- a/docs/whats_new.rst +++ b/docs/whats_new.rst @@ -11,6 +11,17 @@ Changelog This page keeps a detailed human friendly rendering of what's new and changed in specific versions. +.. _vp1p6p0p7: + +v1.6.0.7 +-------- + +New Features +~~~~~~~~~~~~~~ + +- Add :attr:`Cog.aliases` +- Add :attr:`Bot.case_insensitive_prefix` + .. _vp1p5p1p6: v1.5.1.6