From 38508207944443fc038fa73134cee87914d86c7d Mon Sep 17 00:00:00 2001 From: qwewqa <198e559dbd446d973355f415bdfa34@gmail.com> Date: Fri, 15 Jan 2021 02:27:10 -0500 Subject: [PATCH] add id to music search display and sort --- miyu_bot/commands/cogs/event.py | 1 + miyu_bot/commands/cogs/music.py | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/miyu_bot/commands/cogs/event.py b/miyu_bot/commands/cogs/event.py index 3d5abed..2ffd456 100644 --- a/miyu_bot/commands/cogs/event.py +++ b/miyu_bot/commands/cogs/event.py @@ -34,6 +34,7 @@ class Event(commands.Cog): event: EventMaster if arg: + # Allows relative id searches like `!event +1` for next event or `!event -2` for the event before last event if arg[0] in ['-', '+']: try: latest = self.get_latest_event(ctx) diff --git a/miyu_bot/commands/cogs/music.py b/miyu_bot/commands/cogs/music.py index 2c90dd7..81d9872 100644 --- a/miyu_bot/commands/cogs/music.py +++ b/miyu_bot/commands/cogs/music.py @@ -321,6 +321,7 @@ class Music(commands.Cog): class MusicAttribute(enum.Enum): DefaultOrder = enum.auto() Name = enum.auto() + Id = enum.auto() Unit = enum.auto() Level = enum.auto() Duration = enum.auto() @@ -330,6 +331,7 @@ class MusicAttribute(enum.Enum): return { self.DefaultOrder: -music.default_order, self.Name: music.name, + self.Id: music.id, self.Unit: music.unit.name if not music.special_unit_name else f'{music.unit.name} ({music.special_unit_name})', self.Level: music.charts[4].display_level, self.Duration: Music.get_music_duration(music), @@ -340,6 +342,7 @@ class MusicAttribute(enum.Enum): return { self.DefaultOrder: None, self.Name: None, + self.Id: str(music.id).zfill(7), self.Unit: music.unit.name if not music.special_unit_name else f'{music.unit.name} ({music.special_unit_name})', self.Level: music.charts[4].display_level, self.Duration: Music.format_duration(Music.get_music_duration(music)), @@ -350,6 +353,7 @@ class MusicAttribute(enum.Enum): music_attribute_names = { 'default': MusicAttribute.DefaultOrder, 'name': MusicAttribute.Name, + 'id': MusicAttribute.Id, 'relevance': MusicAttribute.Name, 'unit': MusicAttribute.Unit, 'level': MusicAttribute.Level,