How to use the playsound.utils.chat_formatting function in playsound

To help you get started, we’ve selected a few playsound examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github tmercswims / tmerc-cogs / playsound / playsound.py View on Github external
async def sound_play(self, ctx: commands.Context, p: str, vol: int):
        server = ctx.message.server
        if not ctx.message.author.voice_channel:
            await self.bot.reply(
                cf.warning("You need to join a voice channel first."))
            return

        if self.voice_channel_full(ctx.message.author.voice_channel):
            return

        if not ctx.message.channel.is_private:
            if self.voice_connected(server):
                if server.id not in self.audio_players:
                    await self.sound_init(ctx, p, vol)
                    self.audio_players[server.id].start()
                    await self.wait_for_disconnect(server)
                else:
                    if self.audio_players[server.id].is_playing():
                        self.audio_players[server.id].stop()
                    await self.sound_init(ctx, p, vol)
                    self.audio_players[server.id].start()
github tmercswims / tmerc-cogs / playsound / playsound.py View on Github external
await self.bot.type()

        server = ctx.message.server

        if server.id not in os.listdir(self.sound_base):
            os.makedirs(os.path.join(self.sound_base, server.id))

        if server.id not in self.settings:
            self.settings[server.id] = {}
            dataIO.save_json(self.settings_path, self.settings)

        f = glob.glob(os.path.join(self.sound_base, server.id,
                                   soundname + ".*"))
        if len(f) < 1:
            await self.bot.say(cf.error(
                "Sound file not found. Try `{}allsounds` for a list.".format(
                    ctx.prefix)))
            return
        elif len(f) > 1:
            await self.bot.say(cf.error(
                "There are {} sound files with the same name, but different"
                " extensions, and I can't deal with it. Please make filenames"
                " (excluding extensions) unique.".format(len(f))))
            return

        if soundname not in self.settings[server.id]:
            self.settings[server.id][soundname] = {"volume": default_volume}
            dataIO.save_json(self.settings_path, self.settings)

        if percent is None:
            await self.bot.reply("Volume for {} is {}.".format(