def _peek(self, user_id, *, start=1, playlist_name=None):
if start <= 0:
raise dec.UserInputError('Start must be a positive number')
# offset is start -1
items, playlist_name, total = await self._db.show(user_id, start - 1, 20, playlist_name)
if not items:
if start == 1 or total == 0:
await self._bot.whisper('**Playlist** {} **is empty**'.format(playlist_name))
else:
await self._bot.whisper(
'**There are no songs in the playlist** {} **, starting from the** {} **song**'
.format(playlist_name, self._ordinal(start)))
return
reply = '**{} song(s) (out of {}) from playlist** {}**, starting from the **{}**:**\n **>** ' \
.format(len(items), total, playlist_name, self._ordinal(start)) + \
'\n **>** '.join(['[{}] {}'.format(*item) for item in items])
await self._bot.whisper(reply)
评论列表
文章目录