我想让我的不和谐机器人每小时加入一次语音聊天
I'd like to make my discord bot join voice chat every hour
我想每小时加入一次语音聊天并播放 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)
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)
我想每小时加入一次语音聊天并播放 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)
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)