Adding requester field to song embed

This commit is contained in:
Rafael Vargas 2022-01-07 00:59:37 -04:00
parent 8b8e9e603b
commit 27c2ce38b4
5 changed files with 12 additions and 6 deletions

View File

@ -24,6 +24,7 @@ MAX_PRELOAD_SONGS = 10
SONGINFO_UPLOADER = "Uploader: "
SONGINFO_DURATION = "Duration: "
SONGINFO_REQUESTER = 'Requester: '
HELP_SKIP = 'Skip the current playing song'
HELP_RESUME = 'Resumes the song player'

View File

@ -19,6 +19,7 @@ class Music(commands.Cog):
@commands.command(name="play", help=config.HELP_PLAY, aliases=['p', 'tocar'])
async def play(self, ctx, *args):
user_input = " ".join(args)
requester = ctx.author.name
player = self.__get_player(ctx)
if player == None:
@ -31,7 +32,7 @@ class Music(commands.Cog):
await self.__send_embed(ctx, description=result['reason'], colour_name='red')
return
await player.play(ctx, user_input)
await player.play(ctx, user_input, requester)
@commands.command(name="queue", help=config.HELP_QUEUE, aliases=['q', 'fila'])
async def queue(self, ctx):

View File

@ -280,7 +280,11 @@ class Player(commands.Cog):
embedvc.add_field(name=config.SONGINFO_UPLOADER,
value=info['uploader'],
inline=False)
inline=True)
embedvc.add_field(name=config.SONGINFO_REQUESTER,
value=info['requester'],
inline=True)
if 'thumbnail' in info.keys():
embedvc.set_thumbnail(url=info['thumbnail'])

View File

@ -77,9 +77,9 @@ class Playlist(IPlaylist):
else:
return self.__songs_history[0].source
def add_song(self, identifier: str) -> Song:
def add_song(self, identifier: str, requester: str) -> Song:
"""Create a song object, add to queue and return it"""
song = Song(identifier, self) # Cria a musica com o identificador
song = Song(identifier=identifier, playlist=self, requester=requester)
self.__queue.append(song)
return song

View File

@ -4,10 +4,10 @@ from vulkan.music.Interfaces import ISong, IPlaylist
class Song(ISong):
"""Store the usefull information about a Song"""
def __init__(self, identifier: str, playlist: IPlaylist) -> None:
def __init__(self, identifier: str, playlist: IPlaylist, requester: str) -> None:
"""Create a song with only the URL to the youtube song"""
self.__identifier = identifier
self.__info = {}
self.__info = {'requester': requester}
self.__problematic = False
self.__playlist: IPlaylist = playlist