我正在使用此示例代碼: https ://github.com/Rapptz/discord.py/blob/master/examples/basic_voice.py我使用 !yt 命令是因?yàn)?!play 命令存在穩(wěn)定性問(wèn)題。我需要?jiǎng)?chuàng)建一個(gè)消除下載的音樂(lè)文件的功能。我曾想過(guò)每次播放一首歌曲時(shí)都刪除整個(gè)文件夾,但這個(gè)想法對(duì)我來(lái)說(shuō)似乎不太好。誰(shuí)能告訴我該怎么做?
1 回答

慕的地10843
TA貢獻(xiàn)1785條經(jīng)驗(yàn) 獲得超8個(gè)贊
假設(shè)你想把它放在命令中,
@bot.command(name='del')
@commands.is_owner #only bot owner can use this
for folder in os.listdir('./foldermp3filesarestored'):
if folder.endswith('.mp3'):
os.remove(folder)
else:
print("found file not ending in .mp3")
你也可以把它放在 on_ready 的 for 循環(huán)中。
添加回答
舉報(bào)
0/150
提交
取消