我正在使用此示例代码: https ://github.com/Rapptz/discord.py/blob/master/examples/basic_voice.py我使用 !yt 命令是因为 !play 命令存在稳定性问题。我需要创建一个消除下载的音乐文件的功能。我曾想过每次播放一首歌曲时都删除整个文件夹,但这个想法对我来说似乎不太好。谁能告诉我该怎么做?
1 回答
慕的地10843
TA贡献1785条经验 获得超8个赞
假设你想把它放在命令中,
@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 循环中。
添加回答
举报
0/150
提交
取消
