async def change(self, ctx, *, string: Union[LimitedRate, ParseableRate, Diff]): """Either change or slow-change your height. Can be used in essentially the three following ways: `&change <amount>` `&change <amount>/<time>` `&change <amount>/<time> until <size/time>` Examples: `&change +1ft` `&change *2` `&change 50ft/day` `&change -1in/min until 1ft` `&change -1mm/sec for 1hr` """ guildid = ctx.guild.id userid = ctx.author.id if isinstance(string, Diff): style = string.changetype amount = string.amount userdata = userdb.load(guildid, userid) if style == "add": userdata.height += amount elif style == "multiply": userdata.height *= amount elif style == "power": userdata = userdata**amount else: raise ChangeMethodInvalidException await proportions.nickUpdate(ctx.author) userdb.save(userdata) await ctx.send( f"User <@{userid}> is now {userdata.height:m} ({userdata.height:u}) tall." ) elif isinstance(string, ParseableRate) or isinstance( string, LimitedRate): addPerSec, mulPerSec, stopSV, stopTV = Rate.parse(string.original) userdata = userdb.load( guildid, userid ) # Load this data but don't use it as an ad-hoc user test. changes.start(userid, guildid, addPerSec=addPerSec, mulPerSec=mulPerSec, stopSV=stopSV, stopTV=stopTV) await ctx.send( f"{ctx.author.display_name} has begun slow-changing at a rate of `{string.original}`." )
def test_parseRate_words_sub_sizestop(): result = Rate.parse("subtract 6m per 3 seconds until 12m") assert result == (-2, 1, 12, None)
def test_parseRate_words_add_nostop(): result = Rate.parse("add 6m per 3 seconds") assert result == (2, 1, None, None)
def test_parseRate_words_add_timestop(): result = Rate.parse("add 6m per 3 seconds for 10 seconds") assert result == (2, 1, None, 10)
def test_parseRate_symbols_sub_timestop(): result = Rate.parse("-6m/3s->10s") assert result == (-2, 1, None, 10)
def test_parseRate_symbols_add_nostop(): result = Rate.parse("6m/3s") assert result == (2, 1, None, None)
def test_parseRate_words_div_nostop(): result = Rate.parse("divide 8 per 3 seconds") assert result == (0, Decimal(0.5), None, None)
def test_parseRate_words_mult_nostop(): result = Rate.parse("times 8 per 3 seconds") assert result == (0, 2, None, None)
def test_parseRate_symbols_div_timestop(): result = Rate.parse("/8/3s for 10s") assert result == (0, Decimal("0.5"), None, 10)
def test_parseRate_symbols_div_sizestop(): result = Rate.parse("/8/3s until 12m") assert result == (0, Decimal("0.5"), 12, None)
def test_parseRate_symbols_mult_nostop(): result = Rate.parse("x8/3s") assert result == (0, 2, None, None)
def test_parseRate_symbols_mult_timestop(): result = Rate.parse("*8/3s for 10s") assert result == (0, 2, None, 10)
def test_parseRate_symbols_mult_sizestop(): result = Rate.parse("x8/3s until 12m") assert result == (0, 2, 12, None)
def test_parseRate_symbols_sub_nostop(): result = Rate.parse("-6m/3s") assert result == (-2, 1, None, None)
def test_parseRate_words_sub_nostop(): result = Rate.parse("subtract 6m per 3 seconds") assert result == (-2, 1, None, None)
def test_parseRate_words_mult_sizestop(): result = Rate.parse("multiply 8 per 3 seconds until 12m") assert result == (0, 2, 12, None)
def test_parseRate_symbols_div_nostop(): result = Rate.parse("/8/3s") assert result == (0, Decimal("0.5"), None, None)
def test_parseRate_words_div_sizestop(): result = Rate.parse("divide 8 per 3 seconds until 12m") assert result == (0, Decimal(0.5), 12, None)
def test_parseRate_2x(): result = Rate.parse("8x/3s") assert result == (0, 2, None, None)
def test_parseRate_symbols_add_timestop(): result = Rate.parse("add 6m/3s for 10 seconds") assert result == (2, 1, None, 10)
def test_parseRate_omitOne(): result = Rate.parse("2 meters per second") assert result == (2, 1, None, None)
def test_parseRate_symbols_sub_sizestop(): result = Rate.parse("-6m/3s until 12m") assert result == (-2, 1, 12, None)
def test_parseRate_words_add_sizestop(): result = Rate.parse("add 6m per 3 seconds until 12m") assert result == (2, 1, 12, None)