I'm currently making a discord bot playing music, I've been having a lot of problems these days with the song queue so I decided to make my own. I used to read music bot repos and it seems they use some kind of lists optimized specifically for append()
and pop()
. Could someone please enlighten me on this as I think it would be a great improvement in my code.
If you see any other improvements, don't hesitate, I'm interested
class Song_Queue():
def __init__(self):
self.queue = []
async def add_song(self, song, song_name, message_author, song_duration):
queue = self.queue
queue.append([song, song_name, message_author, song_duration])
#self.queue[x] = ...
# x = 0 : fichier son à diffuser
# x = 1 : nom du son
# x = 2 : la durée de la musique
# x = 3 : la personne qui a ajouté la musique au bot
async def get_next_song(self):
queue = self.queue
print(f'{queue}')
return queue[0]
async def remove_song(self):
self.queue.pop(0)
return
async def retrieve_all_data(self):
return self.queue