Fixed attribute semantics

This commit is contained in:
cloudwithax 2021-11-11 17:31:44 -05:00
parent 11e4a34a96
commit 360889e048
2 changed files with 19 additions and 8 deletions

View File

@ -21,6 +21,7 @@ class Player(pomice.Player):
self.queue = asyncio.Queue()
self.controller: discord.Message = None
# Set context here so we can send a now playing embed
self.context: commands.Context = None
self.dj: discord.Member = None
@ -56,11 +57,9 @@ class Player(pomice.Player):
if track.is_stream:
embed = discord.Embed(title="Now playing", description=f":red_circle: **LIVE** [{track.title}]({track.uri}) [{track.requester.mention}]")
embed.set_footer(text=f"Use {track.ctx.prefix}help for more commands!", icon_url=f"{self.client.user.avatar.url}")
self.controller = await self.context.send(embed=embed)
else:
embed = discord.Embed(title=f"Now playing", description=f"[{track.title}]({track.uri}) [{track.requester.mention}]")
embed.set_footer(text=f"Use {track.ctx.prefix}help for more commands!", icon_url=f"{self.client.user.avatar.url}")
self.controller = await self.context.send(embed=embed)
@ -99,6 +98,13 @@ class Music(commands.Cog):
)
print(f"Node is ready!")
# The following are events from pomice.events
# We are using these so that if the track either stops or errors,
# we can just skip to the next track
# Of course, you can modify this to do whatever you like
@commands.Cog.listener()
async def on_pomice_track_end(self, player: Player, track, _):
await player.do_next()
@ -149,7 +155,9 @@ class Music(commands.Cog):
# You can pass in "search_type=" as an argument to change the search type
# i.e: player.get_tracks("query", search_type=SearchType.ytmsearch)
# will search up any keyword results on YouTube Music
results = await player.get_tracks(search)
# We will also set the context here to get special features, like a track.requester object
results = await player.get_tracks(search, ctx=ctx)
if not results:
raise commands.CommandError("No results were found for that search term.")

View File

@ -24,7 +24,7 @@ class Track:
self.info = info
self.spotify = spotify
if self.spotify:
self.original: Optional[Track] = None
self._search_type = search_type
self.spotify_track = spotify_track
@ -77,10 +77,13 @@ class Playlist:
self.tracks_raw = tracks
self.spotify = spotify
self.name = playlist_info.get("name")
self.spotify_playlist = spotify_playlist
self._thumbnail = None
self._uri = None
if self.spotify:
self.tracks = tracks
self.spotify_playlist = spotify_playlist
self._thumbnail = self.spotify_playlist.image
self._uri = self.spotify_playlist.uri
else: