mirror of
https://github.com/uhIgnacio/EmoteManager.git
synced 2024-08-15 02:23:13 +00:00
fix help output for list/export
This commit is contained in:
parent
7e5f01b82d
commit
aa298198f1
2 changed files with 21 additions and 10 deletions
|
@ -13,14 +13,23 @@
|
|||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with Emote Manager. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
import functools
|
||||
|
||||
_emote_type_predicates = {
|
||||
'': lambda _: True, # allow usage as a "consume rest" converter
|
||||
'all': lambda _: True,
|
||||
'static': lambda e: not e.animated,
|
||||
'animated': lambda e: e.animated}
|
||||
|
||||
def emote_type_filter(argument):
|
||||
try:
|
||||
return _emote_type_predicates[argument.lower()]
|
||||
except KeyError:
|
||||
raise commands.BadArgument('Invalid emote type. Specify “static”, “animated”, “all”.')
|
||||
# this is kind of a hack to ensure that the last argument is always converted, even if the default is used.
|
||||
def emote_type_filter_default(command):
|
||||
old_callback = command.callback
|
||||
|
||||
@functools.wraps(old_callback)
|
||||
async def callback(self, ctx, *args):
|
||||
image_type = args[-1]
|
||||
image_type = _emote_type_predicates[image_type]
|
||||
return await old_callback(self, ctx, *args[:-1], image_type)
|
||||
|
||||
command.callback = callback
|
||||
return command
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue