async def setrandomheight(self, ctx, minheight, maxheight): """Change height to a random value. Sets your height to a height between `minheight` and `maxheight`. Weighted on a logarithmic curve.""" minheightSV = utils.clamp(0, SV.parse(minheight), SV._infinity) maxheightSV = utils.clamp(0, SV.parse(maxheight), SV._infinity) newheightSV = decimal.randRangeLog(minheightSV, maxheightSV) userdata = userdb.load(ctx.guild.id, ctx.author.id) userdata.height = newheightSV userdb.save(userdata) logger.info( f"User {ctx.author.id} ({ctx.author.display_name}) set a random height, and are now {userdata.height:m} tall." ) await ctx.send(f"<@{ctx.author.id}> is now {userdata.height:mu} tall.") await proportions.nickUpdate(ctx.author)
def test_clamp_down(): assert utils.clamp(10, 100, 20) == 20
def test_clamp_up(): assert utils.clamp(10, 1, 20) == 10
def progress(self): """Progress 0.0-1.0""" progress = utils.clamp(Decimal(0), (self.now - self.startTime) / self.duration, Decimal(1)) return progress
def buildRun(progress): maxRun = 167 steps = utils.clamp(0, int(progress * maxRun), maxRun) remaining = maxRun - steps return f"\u200b🏁{remaining * ' '}🏃♀️"
def buildNyan(progress): nyanTrail = "<a:nyanTrail:667175870711988254>" nyanCat = "<a:nyanEnd:667175883697684510>" maxRun = 33 steps = utils.clamp(0, int(progress * maxRun), maxRun) return f"\u200b{steps * nyanTrail}{nyanCat}"