mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-06 11:18:54 -05:00
Improved !song (#308)
This commit is contained in:
parent
9f997ed08b
commit
e1791f5560
@ -1609,18 +1609,33 @@ class Audio:
|
|||||||
async def song(self, ctx):
|
async def song(self, ctx):
|
||||||
"""Info about the current song."""
|
"""Info about the current song."""
|
||||||
server = ctx.message.server
|
server = ctx.message.server
|
||||||
if self.is_playing(server):
|
if not self.is_playing(server):
|
||||||
song = self.queue[server.id]["NOW_PLAYING"]
|
await self.bot.say("I'm not playing on this server.")
|
||||||
|
return
|
||||||
|
|
||||||
|
song = self._get_queue_nowplaying(server)
|
||||||
if song:
|
if song:
|
||||||
|
if not hasattr(song, 'creator'):
|
||||||
|
song.creator = None
|
||||||
|
if not hasattr(song, 'view_count'):
|
||||||
|
song.view_count = None
|
||||||
|
if not hasattr(song, 'uploader'):
|
||||||
|
song.uploader = None
|
||||||
|
if hasattr(song, 'duration'):
|
||||||
|
m, s = divmod(song.duration, 60)
|
||||||
|
dur = "{:.0f}:{:.0f}".format(m, s)
|
||||||
|
else:
|
||||||
|
dur = None
|
||||||
msg = ("\n**Title:** {}\n**Author:** {}\n**Uploader:** {}\n"
|
msg = ("\n**Title:** {}\n**Author:** {}\n**Uploader:** {}\n"
|
||||||
"**Views:** {}\n\n<{}>".format(
|
"**Views:** {}\n**Duration:** {}\n\n<{}>".format(
|
||||||
song.title, song.creator, song.uploader,
|
song.title, song.creator, song.uploader,
|
||||||
song.view_count, song.webpage_url))
|
song.view_count, dur, song.webpage_url))
|
||||||
await self.bot.say(msg.replace("**Author:** None\n", ""))
|
await self.bot.say(msg.replace("**Author:** None\n", "")
|
||||||
|
.replace("**Views:** None\n", "")
|
||||||
|
.replace("**Uploader:** None\n", "")
|
||||||
|
.replace("**Duration:** None\n", ""))
|
||||||
else:
|
else:
|
||||||
await self.bot.say("I don't know what this song is either.")
|
await self.bot.say("Darude - Sandstorm.")
|
||||||
else:
|
|
||||||
await self.bot.say("I'm not playing anything on this server.")
|
|
||||||
|
|
||||||
@commands.command(pass_context=True)
|
@commands.command(pass_context=True)
|
||||||
async def stop(self, ctx):
|
async def stop(self, ctx):
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user