async def give(self, ctx, person: discord.Member, amount: Abbreviated): """ Command that gives your Didier Dinks to another user. :param ctx: Discord Context :param person: user to give the Didier Dinks to :param amount: the amount of Didier Dinks to give """ # Invalid amount if amount is None: return # Disable DM abuse if ctx.guild is None: return await ctx.send("Muttn") valid = checks.isValidAmount(ctx, amount) if not valid[0]: return await ctx.send(valid[1]) amount = float(valid[1]) currency.update(ctx.author.id, "dinks", float(currency.dinks(ctx.author.id)) - amount) currency.update(person.id, "dinks", float(currency.dinks(person.id)) + amount) rep = getRep(math.floor(amount), Numbers.t.value) await ctx.send( "**{}** heeft **{}** zowaar **{}** Didier Dink{} geschonken!". format(ctx.author.display_name, person.display_name, rep, checks.pluralS(amount)))
async def award(self, ctx, user: discord.User, amount: Abbreviated): """ Command that awards a user a certain amount of Didier Dinks. :param ctx: Discord Context :param user: the user to give the Didier Dinks to :param amount: the amount of Didier Dinks to award [user] """ # No amount was passed if amount is None: return # Update the db currency.update(user.id, "dinks", float(currency.dinks(user.id)) + float(amount)) # Gets the abbreviated representation of the amount rep = getRep(amount, Numbers.t.value) await ctx.send("**{}** heeft **{}** zowaar **{}** Didier Dink{} beloond!" .format(ctx.author.display_name, self.utilsCog.getDisplayName(ctx, user.id), rep, checks.pluralS(amount)))
async def buy(self, ctx, item, amount: Abbreviated = 1): if amount is None: return try: item = int(item) except ValueError: return await ctx.send("Dit is geen geldig id.") success, message = store.buy(ctx, ctx.author.id, item, amount) if not success: return await ctx.send(message) rep = getRep(message["price"], Numbers.t.value) return await ctx.send( "**{}** heeft **{} {}{}** gekocht voor **{}** Didier Dink{}.". format(ctx.author.display_name, amount, message["name"], checks.pluralS(amount), rep, checks.pluralS(message["price"])))
async def sell(self, ctx, itemid, amount: Abbreviated = 1): if amount is None: return try: itemid = int(itemid) except ValueError: return await ctx.send("Dit is geen geldig id.") inv = store.inventory(ctx.author.id) if not inv or not any(int(item[0]) == itemid for item in inv): return await ctx.send("Je hebt geen item met dit id.") item_tuple = None for item in inv: if item[0] == itemid: item_tuple = item break if str(amount).lower() == "all": amount = int(item_tuple[2]) if int(item_tuple[2]) < amount: return await ctx.send("Je hebt niet zoveel {}s.".format( item_tuple[1])) store.sell(int(ctx.author.id), itemid, int(amount), int(item_tuple[2])) price = int(store.getItemPrice(itemid)[0]) returnValue = round(0.8 * (price * amount)) currency.update(ctx.author.id, "dinks", currency.dinks(ctx.author.id) + returnValue) await ctx.send( "**{}** heeft **{} {}{}** verkocht voor **{}** Didier Dinks!". format(ctx.author.display_name, amount, item_tuple[1], "s" if amount != 1 else "", getRep(returnValue, Numbers.t.value)))