testsoundboard.py 文件源码

python
阅读 19 收藏 0 点赞 0 评论 0

项目:nyx 作者: Cappycot 项目源码 文件源码
def play_file(self, ctx, sound, volume=1):
        """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()

        def done(e):
            if e:
                print("Player error: %s" % e)
            if not ctx.voice_client.is_playing():
                ctx.bot.loop.create_task(ctx.voice_client.disconnect())

        source = discord.PCMVolumeTransformer(
            discord.FFmpegPCMAudio(join(folder, sound)))
        source.volume = volume
        ctx.voice_client.play(source, after=done)

        # await ctx.send('Now playing: {}'.format(query))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号