async def my_after(ctx):
#os.remove(f"songs/{ctx.guild.id}.mp3")
voice_state = ctx.guild.voice_client
if not voice_state.is_playing:
stats = False
names = []
requesters = []
artists = []
ids = []
albumids = []
positions = []
guilds = []
lyrics = []
with sqlite3.connect("database.db") as db:
c = db.cursor()
for n, r, a, i, ai, ly, g, p in c.execute("SELECT * FROM songs WHERE guild = ?", (ctx.guild.id,)):
positions.append(p)
names.append(n)
requesters.append(r)
artists.append(a)
guilds.append(g)
ids.append(i)
albumids.append(ai)
if n and not ly:
lyrics.append(None)
else:
lyrics.append(ly)
c.execute("DELETE FROM songs WHERE guild = ? AND position = ?", (guilds[0], positions[0],))
print("Success removed")
whats = False
try:
whats = positions[1]
whats = True
except:
whats = False
return
if whats:
#Song.download_track(ctx, {"id": ids[1], "title": names[1], "artist": artists[1], "albumid": albumids[1], "lyrics": lyrics[1]})
await Song.play(ctx)
async def play(ctx):
voice_state = ctx.guild.voice_client
if not voice_state:
error = await Song.join_channel(ctx)
if error:
return error
voice_state = ctx.guild.voice_client
if voice_state.is_playing():
return "alreadyPlay"
ids = []
with sqlite3.connect("database.db") as db:
c = db.cursor()
for n, r, a, i, ai, ly, g, p in c.execute("SELECT * FROM songs WHERE guild = ?", (ctx.guild.id,)):
ids.append(i)
if not os.path.isfile(f"songs/{ids[0]}.mp3"):
Song.download_track(ctx, {'id': ids[0]})
loop = asyncio.get_running_loop().create_task(Song.my_after(ctx))
asyncio.set_event_loop(loop)
voice_state.play(disnake.FFmpegPCMAudio(f"songs/{ids[0]}.mp3"), after=lambda ex: loop)
return None
Но из-за чего то начало возвращать ошибку:
AssertionError:
Как это тогда сделать?