rewrite: Setting input strings and localisation.
This commit is contained in:
@@ -787,9 +787,23 @@ class Economy(LionCog):
|
||||
"Configure LionCoin Economy"
|
||||
)
|
||||
)
|
||||
@appcmds.rename(
|
||||
allow_transfers=EconomySettings.AllowTransfers._display_name,
|
||||
coins_per_xp=EconomySettings.CoinsPerXP._display_name
|
||||
)
|
||||
@appcmds.describe(
|
||||
allow_transfers=EconomySettings.AllowTransfers._desc,
|
||||
coins_per_xp=EconomySettings.CoinsPerXP._desc
|
||||
)
|
||||
@appcmds.choices(
|
||||
allow_transfers=[
|
||||
appcmds.Choice(name=EconomySettings.AllowTransfers._outputs[True], value=1),
|
||||
appcmds.Choice(name=EconomySettings.AllowTransfers._outputs[False], value=0),
|
||||
]
|
||||
)
|
||||
@cmds.check(low_management)
|
||||
async def configure_economy(self, ctx: LionContext,
|
||||
allow_transfers: Optional[bool] = None,
|
||||
allow_transfers: Optional[appcmds.Choice[int]] = None,
|
||||
coins_per_xp: Optional[appcmds.Range[int, 0, 2**15]] = None):
|
||||
t = self.bot.translator.t
|
||||
if not ctx.interaction:
|
||||
@@ -802,7 +816,7 @@ class Economy(LionCog):
|
||||
|
||||
modified = []
|
||||
if allow_transfers is not None:
|
||||
setting_allow_transfers.data = allow_transfers
|
||||
setting_allow_transfers.data = bool(allow_transfers.value)
|
||||
await setting_allow_transfers.write()
|
||||
modified.append(setting_allow_transfers)
|
||||
if coins_per_xp is not None:
|
||||
|
||||
@@ -10,6 +10,7 @@ from settings.groups import SettingGroup
|
||||
from settings.data import ModelData, ListData
|
||||
from settings.setting_types import ChannelListSetting, IntegerSetting, BoolSetting
|
||||
|
||||
from meta.context import ctx_bot
|
||||
from meta.config import conf
|
||||
from meta.sharding import THIS_SHARD
|
||||
from meta.logger import log_wrap
|
||||
@@ -40,6 +41,10 @@ class EconomySettings(SettingGroup):
|
||||
'guildset:coins_per_xp|long_desc',
|
||||
"Members will be rewarded with this many LionCoins for every 100 XP they earn."
|
||||
)
|
||||
_accepts = _p(
|
||||
'guildset:coins_per_xp|long_desc',
|
||||
"The number of coins to reward per 100 XP."
|
||||
)
|
||||
# This default needs to dynamically depend on the guild mode!
|
||||
_default = 50
|
||||
|
||||
@@ -54,6 +59,11 @@ class EconomySettings(SettingGroup):
|
||||
"For every **100** XP they earn, members will now be given {coin}**{amount}**."
|
||||
)).format(amount=self.value, coin=conf.emojis.coin)
|
||||
|
||||
@property
|
||||
def set_str(self):
|
||||
bot = ctx_bot.get()
|
||||
return bot.core.mention_cmd('configure economy') if bot else None
|
||||
|
||||
class AllowTransfers(ModelData, BoolSetting):
|
||||
setting_id = 'allow_transfers'
|
||||
|
||||
@@ -64,9 +74,40 @@ class EconomySettings(SettingGroup):
|
||||
)
|
||||
_long_desc = _p(
|
||||
'guildset:allow_transfers|long_desc',
|
||||
"If disabled, members will not be able to use `/sendcoins` to transfer LionCoinds."
|
||||
"If disabled, members will not be able to transfer LionCoins to each other."
|
||||
)
|
||||
_default = True
|
||||
|
||||
_model = CoreData.Guild
|
||||
_column = CoreData.Guild.allow_transfers.name
|
||||
|
||||
_outputs = {
|
||||
True: _p('guildset:allow_transfers|outputs:true', "Enabled (Coin transfers allowed.)"),
|
||||
False: _p('guildset:allow_transfers|outputs:false', "Disabled (Coin transfers not allowed.)"),
|
||||
}
|
||||
_outputs[None] = _outputs[_default]
|
||||
|
||||
@property
|
||||
def set_str(self):
|
||||
bot = ctx_bot.get()
|
||||
return bot.core.mention_cmd('configure economy') if bot else None
|
||||
|
||||
@property
|
||||
def update_message(self):
|
||||
t = ctx_translator.get().t
|
||||
bot = ctx_bot.get()
|
||||
if self.value:
|
||||
formatted = t(_p(
|
||||
'guildset:allow_transfers|set_response|set:true',
|
||||
"Members will now be able to use {send_cmd} to transfer {coin}"
|
||||
))
|
||||
else:
|
||||
formatted = t(_p(
|
||||
'guildset:allow_transfers|set_response|set:false',
|
||||
"Members will not be able to use {send_cmd} to transfer {coin}"
|
||||
))
|
||||
formatted = formatted.format(
|
||||
send_cmd=bot.core.mention_cmd('send'),
|
||||
coin=conf.emojis.coin
|
||||
)
|
||||
return formatted
|
||||
|
||||
@@ -65,7 +65,7 @@ class EconomyConfigUI(ConfigUI):
|
||||
class EconomyDashboard(DashboardSection):
|
||||
section_name = _p(
|
||||
'dash:economy|title',
|
||||
"Economy Configuration"
|
||||
"Economy Configuration ({commands[configure economy]})"
|
||||
)
|
||||
configui = EconomyConfigUI
|
||||
setting_classes = EconomyConfigUI.setting_classes
|
||||
|
||||
Reference in New Issue
Block a user