Example #1
0
 async def admingiveall(self, ctx, amount: float):
     """(Owner) Grant everyone gil."""
     if amount < 0:
         await ctx.send(CMD_GIVE_INVALID_AMOUNT)
         return
     all_accounts = EconomyAccount.get_all_economy_accounts(
         self.bot.db_session)
     for _account in all_accounts:
         _account.add_credit(self.bot.db_session, amount, "Admin grant.")
     await ctx.send("**Compensation finished.**")
Example #2
0
    async def purgeaccounts(self, ctx):
        """(Owner) Purge all accounts with transactions less than 5."""
        all_accounts = EconomyAccount.get_all_economy_accounts(
            self.bot.db_session)
        for _account in all_accounts:
            if len(_account.transactions) <= 5:
                logging.info("Deleting {}...".format(_account))
                self.bot.db_session.delete(_account)

        await ctx.send("**Purging finished.**")
Example #3
0
 async def reconsolidateall(self, ctx, target: discord.Member = None):
     """(Owner) Reconsolidate the whole database's balances."""
     if target is None:
         all_accounts = EconomyAccount.get_all_economy_accounts(
             self.bot.db_session)
         inconsistent_accounts = 0
         for account in all_accounts:
             # We disable committing here to optimize SQL query execution time
             result = account.reconsolidate_balance(
                 self.bot.db_session, commit_on_execution=False)
             if not result:
                 inconsistent_accounts += 1
         self.bot.db_session.commit()
         await ctx.send(
             CMD_RECONSOLIDATE_MASS.format(len(all_accounts),
                                           inconsistent_accounts))
     else:
         target_account = EconomyAccount.get_economy_account(
             target, self.bot.db_session)
         result = target_account.reconsolidate_balance(self.bot.db_session)
         if result:
             await ctx.send(CMD_RECONSOLIDATE_TRUE.format(target))
         else:
             await ctx.send(CMD_RECONSOLIDATE_FALSE.format(target))