def play_file(self, ctx, *, query):
"""Plays a file from the local filesystem"""
if ctx.voice_client is None:
if ctx.author.voice.channel:
await ctx.author.voice.channel.connect()
else:
return await ctx.send("Not connected to a voice channel.")
if ctx.voice_client.is_playing():
ctx.voice_client.stop()
source = discord.PCMVolumeTransformer(discord.FFmpegPCMAudio(query))
ctx.voice_client.play(source, after=lambda e: print(
'Player error: %s' % e) if e else None)
await ctx.send('Now playing: {}'.format(query))
评论列表
文章目录