[Topgg][Admin][Economy] Implement addCoins cb
This commit is contained in:
@@ -60,7 +60,7 @@ async def cmd_send(ctx):
|
||||
return await ctx.embed_reply("We are still waiting for {} to open an account.".format(target.mention))
|
||||
|
||||
# Finally, send the amount and the ack message
|
||||
target_lion.addCoins(amount)
|
||||
target_lion.addCoins(amount, ignorebonus=True)
|
||||
source_lion.addCoins(-amount)
|
||||
|
||||
embed = discord.Embed(
|
||||
|
||||
@@ -61,10 +61,10 @@ async def cmd_set(ctx):
|
||||
# Postgres `coins` column is `integer`, sanity check postgres int limits - which are smalled than python int range
|
||||
target_coins_to_set = target_lion.coins + amount
|
||||
if target_coins_to_set >= 0 and target_coins_to_set <= POSTGRES_INT_MAX:
|
||||
target_lion.addCoins(amount)
|
||||
target_lion.addCoins(amount, ignorebonus=True)
|
||||
elif target_coins_to_set < 0:
|
||||
target_coins_to_set = -target_lion.coins # Coins cannot go -ve, cap to 0
|
||||
target_lion.addCoins(target_coins_to_set)
|
||||
target_lion.addCoins(target_coins_to_set, ignorebonus=True)
|
||||
target_coins_to_set = 0
|
||||
else:
|
||||
return await ctx.embed_reply("Member coins cannot be more than {}".format(POSTGRES_INT_MAX))
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import asyncio
|
||||
from codecs import ignore_errors
|
||||
import logging
|
||||
import traceback
|
||||
import datetime
|
||||
@@ -500,7 +501,7 @@ class ReactionRoleMessage:
|
||||
if price and refund:
|
||||
# Give the user the refund
|
||||
lion = Lion.fetch(self.guild.id, member.id)
|
||||
lion.addCoins(price)
|
||||
lion.addCoins(price, ignorebonus=True)
|
||||
|
||||
# Notify the user
|
||||
embed = discord.Embed(
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
from multiprocessing import context
|
||||
from LionModule import LionModule
|
||||
from LionContext import register_reply_callback, unregister_reply_callback
|
||||
from bot.data.conditions import NOT
|
||||
from meta.client import client
|
||||
from core.lion import register_addcoins_callback, unregister_addcoins_callback
|
||||
|
||||
from .utils import *
|
||||
from .webhook import init_webhook
|
||||
@@ -14,12 +16,14 @@ upvote_info = "You have a boost available {}, to support our project and earn **
|
||||
async def register_hook(client):
|
||||
init_webhook()
|
||||
register_reply_callback(reply)
|
||||
register_addcoins_callback(cb_addCoins)
|
||||
|
||||
client.log("Registered LionContext reply util hook.", context="Topgg" )
|
||||
|
||||
@module.unload_task
|
||||
async def unregister_hook(client):
|
||||
unregister_reply_callback(reply)
|
||||
unregister_addcoins_callback(cb_addCoins)
|
||||
|
||||
client.log("Unregistered LionContext reply util hook.", context="Topgg" )
|
||||
|
||||
@@ -51,3 +55,14 @@ def reply(util_func, *args, **kwargs):
|
||||
args = tuple(args)
|
||||
|
||||
return [args, kwargs]
|
||||
|
||||
|
||||
def cb_addCoins(self, amount, flush, ignorebonus):
|
||||
|
||||
client.log('cb_addCoins hook with amount={} ignorebonux={}'.format(amount, ignorebonus), context='Topgg')
|
||||
|
||||
if not ignorebonus and amount > 0 and get_last_voted_timestamp(self.userid):
|
||||
amount *= 1.25
|
||||
client.log('cb_addCoins with bonus={}'.format(amount), context='Topgg')
|
||||
|
||||
return [self, amount, flush, ignorebonus]
|
||||
Reference in New Issue
Block a user