fix: optimize database logic, fixed #93

This commit is contained in:
Terry Geng
2020-03-10 09:23:36 +08:00
parent d653eceb2a
commit a39199d54d
3 changed files with 21 additions and 15 deletions

View File

@ -456,8 +456,9 @@ class AutoPlaylist(OneshotPlaylist):
def refresh(self):
dicts = var.music_db.query_random_music(var.config.getint("bot", "autoplay_length", fallback=5))
_list = [get_item_wrapper_from_dict(var.bot, _dict, "AutoPlay") for _dict in dicts]
self.from_list(_list, -1)
if dicts:
_list = [get_item_wrapper_from_dict(var.bot, _dict, "AutoPlay") for _dict in dicts]
self.from_list(_list, -1)
# def from_list(self, _list, current_index):
# self.version += 1