mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-06 11:18:54 -05:00
[Audio] Add thumbnail display with toggle (#1998)
* [V3 Audio] Add thumbnail display with toggle * [V3 Audio] Add thumbnail to notify messages * Formatting * Update thumbnail fetching * Update thumbnail fetching * Track thumbnail moved to Red-Lavalink * Formatting
This commit is contained in:
parent
03d49bac53
commit
dd5ef3696f
@ -15,7 +15,7 @@ from .manager import shutdown_lavalink_server
|
|||||||
|
|
||||||
_ = Translator("Audio", __file__)
|
_ = Translator("Audio", __file__)
|
||||||
|
|
||||||
__version__ = "0.0.6c"
|
__version__ = "0.0.6d"
|
||||||
__author__ = ["aikaterna", "billy/bollo/ati"]
|
__author__ = ["aikaterna", "billy/bollo/ati"]
|
||||||
|
|
||||||
|
|
||||||
@ -46,6 +46,7 @@ class Audio:
|
|||||||
"notify": False,
|
"notify": False,
|
||||||
"repeat": False,
|
"repeat": False,
|
||||||
"shuffle": False,
|
"shuffle": False,
|
||||||
|
"thumbnail": False,
|
||||||
"volume": 100,
|
"volume": 100,
|
||||||
"vote_enabled": False,
|
"vote_enabled": False,
|
||||||
"vote_percent": 0,
|
"vote_percent": 0,
|
||||||
@ -105,6 +106,11 @@ class Audio:
|
|||||||
title="Now Playing",
|
title="Now Playing",
|
||||||
description="**[{}]({})**".format(player.current.title, player.current.uri),
|
description="**[{}]({})**".format(player.current.title, player.current.uri),
|
||||||
)
|
)
|
||||||
|
if (
|
||||||
|
await self.config.guild(player.channel.guild).thumbnail()
|
||||||
|
and player.current.thumbnail
|
||||||
|
):
|
||||||
|
embed.set_thumbnail(url=player.current.thumbnail)
|
||||||
notify_message = await notify_channel.send(embed=embed)
|
notify_message = await notify_channel.send(embed=embed)
|
||||||
player.store("notify_message", notify_message)
|
player.store("notify_message", notify_message)
|
||||||
|
|
||||||
@ -267,6 +273,7 @@ class Audio:
|
|||||||
emptydc_timer = data["emptydc_timer"]
|
emptydc_timer = data["emptydc_timer"]
|
||||||
jukebox = data["jukebox"]
|
jukebox = data["jukebox"]
|
||||||
jukebox_price = data["jukebox_price"]
|
jukebox_price = data["jukebox_price"]
|
||||||
|
thumbnail = data["thumbnail"]
|
||||||
jarbuild = redbot.core.__version__
|
jarbuild = redbot.core.__version__
|
||||||
|
|
||||||
vote_percent = data["vote_percent"]
|
vote_percent = data["vote_percent"]
|
||||||
@ -284,6 +291,8 @@ class Audio:
|
|||||||
"Song notify msgs: [{notify}]\n"
|
"Song notify msgs: [{notify}]\n"
|
||||||
"Songs as status: [{status}]\n".format(**global_data, **data)
|
"Songs as status: [{status}]\n".format(**global_data, **data)
|
||||||
)
|
)
|
||||||
|
if thumbnail:
|
||||||
|
msg += "Thumbnails: [{0}]\n".format(thumbnail)
|
||||||
if vote_percent > 0:
|
if vote_percent > 0:
|
||||||
msg += (
|
msg += (
|
||||||
"Vote skip: [{vote_enabled}]\n" "Skip percentage: [{vote_percent}%]\n"
|
"Vote skip: [{vote_enabled}]\n" "Skip percentage: [{vote_percent}%]\n"
|
||||||
@ -298,6 +307,14 @@ class Audio:
|
|||||||
embed = discord.Embed(colour=ctx.guild.me.top_role.colour, description=msg)
|
embed = discord.Embed(colour=ctx.guild.me.top_role.colour, description=msg)
|
||||||
return await ctx.send(embed=embed)
|
return await ctx.send(embed=embed)
|
||||||
|
|
||||||
|
@audioset.command()
|
||||||
|
@checks.mod_or_permissions(administrator=True)
|
||||||
|
async def thumbnail(self, ctx):
|
||||||
|
"""Toggle displaying a thumbnail on audio messages."""
|
||||||
|
thumbnail = await self.config.guild(ctx.guild).thumbnail()
|
||||||
|
await self.config.guild(ctx.guild).thumbnail.set(not thumbnail)
|
||||||
|
await self._embed_msg(ctx, "Thumbnail display: {}.".format(not thumbnail))
|
||||||
|
|
||||||
@audioset.command()
|
@audioset.command()
|
||||||
@checks.mod_or_permissions(administrator=True)
|
@checks.mod_or_permissions(administrator=True)
|
||||||
async def vote(self, ctx, percent: int):
|
async def vote(self, ctx, percent: int):
|
||||||
@ -435,6 +452,8 @@ class Audio:
|
|||||||
embed = discord.Embed(
|
embed = discord.Embed(
|
||||||
colour=ctx.guild.me.top_role.colour, title="Now Playing", description=song
|
colour=ctx.guild.me.top_role.colour, title="Now Playing", description=song
|
||||||
)
|
)
|
||||||
|
if await self.config.guild(ctx.guild).thumbnail() and player.current.thumbnail:
|
||||||
|
embed.set_thumbnail(url=player.current.thumbnail)
|
||||||
message = await ctx.send(embed=embed)
|
message = await ctx.send(embed=embed)
|
||||||
player.store("np_message", message)
|
player.store("np_message", message)
|
||||||
|
|
||||||
@ -1154,6 +1173,8 @@ class Audio:
|
|||||||
title="Queue for " + ctx.guild.name,
|
title="Queue for " + ctx.guild.name,
|
||||||
description=queue_list,
|
description=queue_list,
|
||||||
)
|
)
|
||||||
|
if await self.config.guild(ctx.guild).thumbnail() and player.current.thumbnail:
|
||||||
|
embed.set_thumbnail(url=player.current.thumbnail)
|
||||||
queue_duration = await self._queue_duration(ctx)
|
queue_duration = await self._queue_duration(ctx)
|
||||||
queue_total_duration = lavalink.utils.format_time(queue_duration)
|
queue_total_duration = lavalink.utils.format_time(queue_duration)
|
||||||
text = "Page {}/{} | {} tracks, {} remaining".format(
|
text = "Page {}/{} | {} tracks, {} remaining".format(
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user