randomshizzle.py 文件源码

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

项目:PTSCogs 作者: PlanetTeamSpeakk 项目源码 文件源码
def rainbow(self, times:int, interval:float):
        """Make a happy rainbow!"""
        rainbow = await self.bot.say(embed=discord.Embed(title="Rainbow!", color=discord.Color.red()))
        time = 0
        error = 0
        if interval < 1.4:
            interval = 1.5
        while times > time:
            time = time + 1
            color = ''.join([choice('0123456789ABCDEF') for x in range(6)])
            color = int(color, 16)
            try:
                await self.bot.edit_message(rainbow, embed=discord.Embed(title="Rainbow!", color=discord.Color(value=color)))
            except:
                if error < 1:
                    await self.bot.say("An error occured, trying again.")
                    error = error + 1
                else:
                    await self.bot.say("Another error occured, exiting.")
                    return
            await asyncio.sleep(interval)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号