我想每小时加入一次语音聊天并播放 mp3 文件,使用 discord.py
@client.command()
async def join(ctx):
channel = ctx.author.voice.channel
voice = await channel.connect()
source = FFmpegPCMAudio('sound.mp3')
player = voice.play(source)
答案 0 :(得分:0)
对 documentation's 示例稍作修改的版本是:
from discord.ext import tasks, commands
class MyCog(commands.Cog):
def cog_unload(self):
self.joiner.cancel()
@tasks.loop(hours=1)
async def joiner(self):
channel = self.bot.get_channel(<id>)
voice = await channel.connect()
source = FFmpegPCMAudio('sound.mp3')
player = voice.play(source)