นี่คือรหัสที่ฉันต้อง:
@commands.command(pass_context=True, aliases= ["aq"])
async def add_queue(self, ctx, *, url):
a = ctx.message.guild.id
b = servers[a]
global queue
try:
b[len(b)] = url
user = ctx.message.author.mention
await ctx.send(f'``{url}`` was added to the queue by {user}!')
except:
await ctx.send(f"Couldnt add {url} to the queue!")
@commands.command(pass_context=True, aliases= ["qp"], case_insensitive=True)
async def pq(self,ctx, number):
a = ctx.message.guild.id
b = servers[a]
if int(number) in b:
source = b[int(number)]
self.cur_song_id = int(number)
await ctx.send(f"**Now Playing:** {source}")
await self.transformer(ctx, source)
async def transformer(self,ctx, url):
player = await YTDLSource.from_url(url, loop=self.bot.loop, stream=True)
if not ctx.message.author.voice:
await ctx.send("You are not connected to a voice channel!")
return
elif ctx.voice_client and ctx.voice_client.is_connected():
print('Already connected to voice')
pass
else:
channel = ctx.message.author.voice.channel
await ctx.send(f'Connected to ``{channel}``')
await channel.connect()
ctx.voice_client.play(player)
ฉันสามารถสร้างแยกคิวการพิมพ์สำหรับแต่ละเซิร์ฟเวอร์และเพิ่มเพลงต้องมันโดยคำสั่ง:
-aq song_name
ตัวอย่างเช่นคิว:
Your current queue is {0: 'abcdefu', 1: 'stereo hearts', 2: 'shivers'}
ฉันสามารถเล่นเพลงที่อยู่ในคิวด้วยคำสั่ง:
-pq 0 or -pq 1 or -pq 2
แต่ปัญหาคือ bot เป่าหีบเพลงเป็นอย่างเดียวที่หนึ่งเพลงและหยุดหลังจากที่มันจะเสร็จแล้วฉันต้องการ bot ที่จะเล่นต่อไปหลังจากเพลงปัจจุบันเพลงเสร็จกันต่อจนกระทั่งเมื่อเพลงที่อยู่ในคิวเล่นอย่างไร
ได้โปรดช่วยฉันออกไปกับเรื่องนี้...
ขอบคุณล่วงหน้า!!!