Ejemplo n.º 1
0
 async def _run(self):
     database.set_settings_candy_chance(self.message.guild.id,
                                        self.candy.id, self.amount)
     candy = database.get_candy(self.message.guild.id)
     new_chance = utils.chance_value_to_percent(candy)[self.candy]
     await self.send(
         f"{self.candy} chance has been changed to {new_chance:.2f}%")
Ejemplo n.º 2
0
 async def _run(self):
     candy = self.args["candy"]
     amount = self.args["amount"]
     database.set_settings_candy_chance(self.server.id, candy.id, amount)
     candy = database.get_candy(self.server.id)
     new_chance = utils.chance_value_to_percent(candy)[candy]
     await self.send(f"{candy} chance has been changed to {new_chance:.2f}%"
                     )
Ejemplo n.º 3
0
def to_candy(arg, server):
    candys = database.get_candy(server.id)
    for candy in candys:
        if (arg == candy.name) or (arg == candy.emoji):
            return candy
    raise ArgumentError
Ejemplo n.º 4
0
 async def _run(self):
     candy = database.get_candy(self.message.guild.id)
     candy_chance = utils.chance_value_to_percent(candy)
     lines = [f"{x.emoji} {x.name} {candy_chance[x]:.2f}%" for x in candy]
     await self.send("\n".join(lines))
Ejemplo n.º 5
0
def get_random_candy(server):
    candy = database.get_candy(server)
    if not candy:
        raise exceptions.CandyError(f"This server has not set up any Candy")
    weights = [x.chance for x in candy]
    return utils.get_choice(candy, weights)