Cleaned up around xp.yml. Fixed a typo, added an error to .xpshop if the feature is disabled.

This commit is contained in:
Kwoth
2022-07-27 03:56:10 +02:00
parent 25fce1bd75
commit 22bff7838a
6 changed files with 75 additions and 5 deletions

View File

@@ -347,6 +347,12 @@ public partial class Xp : NadekoModule<XpService>
[Cmd]
public async Task XpShop()
{
if (!_service.IsShopEnabled())
{
await ReplyErrorLocalizedAsync(strs.xp_shop_disabled);
return;
}
await SendConfirmAsync(GetText(strs.available_commands), $@"`{prefix}xpshop bgs`
`{prefix}xpshop frames`");
}

View File

@@ -43,7 +43,7 @@ Leave at 'None' if patron system is disabled or you don't want any restrictions"
[Comment(@"Frames available for sale. Keys are unique IDs.
Do not change keys as they are not publicly visible. Only change properties (name, price, id)
Removing a key compeltely means all previous purchases will also be unusable.
Removing a key which previously existed means that all previous purchases will also be unusable.
To remove an item from the shop, but keep previous purchases, set the price to -1")]
public Dictionary<string, ShopItemInfo>? Frames { get; set; } = new()
{
@@ -52,7 +52,7 @@ To remove an item from the shop, but keep previous purchases, set the price to -
[Comment(@"Backgrounds available for sale. Keys are unique IDs.
Do not change keys as they are not publicly visible. Only change properties (name, price, id)
Removing a key compeltely means all previous purchases will also be unusable.
Removing a key which previously existed means that all previous purchases will also be unusable.
To remove an item from the shop, but keep previous purchases, set the price to -1")]
public Dictionary<string, ShopItemInfo>? Bgs { get; set; } = new()
{

View File

@@ -33,6 +33,11 @@ public sealed class XpConfigService : ConfigServiceBase<XpConfig>
ConfigPrinters.ToString,
x => x > 0);
AddParsedProp("shop.is_enabled",
conf => conf.Shop.IsEnabled,
bool.TryParse,
ConfigPrinters.ToString);
Migrate();
}

View File

@@ -1470,6 +1470,9 @@ public class XpService : INService, IReadyExecutor, IExecNoCommand
public PatronTier GetXpShopTierRequirement()
=> _xpConfig.Data.Shop.TierRequirement;
public bool IsShopEnabled()
=> _xpConfig.Data.Shop.IsEnabled;
}
public enum BuyResult

View File

@@ -15,13 +15,13 @@ shop:
# Whether the xp shop is enabled
# True -> Users can access the xp shop using .xpshop command
# False -> Users can't access the xp shop
isEnabled: true
isEnabled: false
# Which patron tier do users need in order to use the .xpshop command
# Leave at 'None' if patron system is disabled or you don't want any restrictions
tierRequirement: None
# Frames available for sale. Keys are unique IDs.
# Do not change keys as they are not publicly visible. Only change properties (name, price, id)
# Removing a key completely means all previous purchases will also be unusable.
# Removing a key which previously existed means that all previous purchases will also be unusable.
# To remove an item from the shop, but keep previous purchases, set the price to -1
frames:
default:
@@ -35,7 +35,7 @@ shop:
desc:
# Backgrounds available for sale. Keys are unique IDs.
# Do not change keys as they are not publicly visible. Only change properties (name, price, id)
# Removing a key completely means all previous purchases will also be unusable.
# Removing a key which previously existed means that all previous purchases will also be unusable.
# To remove an item from the shop, but keep previous purchases, set the price to -1
bgs:
default: