mirror of
https://gitlab.com/Kwoth/nadekobot.git
synced 2025-09-10 17:28:27 -04:00
added botcut setting to gambling.yml in which you can configure shopcut for now (how much money the bot takes when something is sold in the shop)
This commit is contained in:
@@ -33,6 +33,8 @@ Experimental changelog. Mostly based on [keepachangelog](https://keepachangelog.
|
||||
- Added `.clubrename` command to uh rename your club
|
||||
- For self-hosters:
|
||||
- Added `.sqlselectcsv` which will return results in a csv file instead of an embed.
|
||||
- You can now configure whether nadeko ignores other bots in `bot.yml`
|
||||
- You can now configure shop sale cut in `gambling.yml`
|
||||
- Added a page parameter to `.feedlist`
|
||||
- Added seconds/sec/s to .convert command
|
||||
|
||||
|
@@ -43,6 +43,9 @@ public sealed partial class GamblingConfig : ICloneable<GamblingConfig>
|
||||
[Comment("""How much will each user's owned currency decay over time.""")]
|
||||
public DecayConfig Decay { get; set; }
|
||||
|
||||
[Comment("""What is the bot's cut on some transactions""")]
|
||||
public BotCutConfig BotCuts { get; set; }
|
||||
|
||||
[Comment("""Settings for LuckyLadder command""")]
|
||||
public LuckyLadderSettings LuckyLadder { get; set; }
|
||||
|
||||
@@ -75,6 +78,7 @@ public sealed partial class GamblingConfig : ICloneable<GamblingConfig>
|
||||
Decay = new();
|
||||
Slots = new();
|
||||
LuckyLadder = new();
|
||||
BotCuts = new();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -385,3 +389,16 @@ public sealed partial class BetRollPair
|
||||
public int WhenAbove { get; set; }
|
||||
public float MultiplyBy { get; set; }
|
||||
}
|
||||
|
||||
[Cloneable]
|
||||
public sealed partial class BotCutConfig
|
||||
{
|
||||
[Comment("""
|
||||
Shop sale cut percentage.
|
||||
Whenever a user buys something from the shop, bot will take a cut equal to this percentage.
|
||||
The rest goes to the user who posted the item/role/whatever to the shop.
|
||||
This is a good way to reduce the amount of currency in circulation therefore keeping the inflation in check.
|
||||
Default 0.1 (10%).
|
||||
""")]
|
||||
public decimal ShopSaleCut { get; set; } = 0.1m;
|
||||
}
|
@@ -182,5 +182,13 @@ public sealed class GamblingConfigService : ConfigServiceBase<GamblingConfig>
|
||||
c.Version = 6;
|
||||
});
|
||||
}
|
||||
|
||||
if (data.Version < 7)
|
||||
{
|
||||
ModifyConfig(c =>
|
||||
{
|
||||
c.Version = 7;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
@@ -283,8 +283,8 @@ public partial class Gambling
|
||||
}
|
||||
}
|
||||
|
||||
private static long GetProfitAmount(int price)
|
||||
=> (int)Math.Ceiling(0.90 * price);
|
||||
private long GetProfitAmount(int price)
|
||||
=> (int)Math.Ceiling((1.0m - Config.BotCuts.ShopSaleCut) * price);
|
||||
|
||||
[Cmd]
|
||||
[RequireContext(ContextType.Guild)]
|
||||
|
@@ -13,7 +13,7 @@ namespace NadekoBot.Common.Configs;
|
||||
public sealed partial class BotConfig : ICloneable<BotConfig>
|
||||
{
|
||||
[Comment("""DO NOT CHANGE""")]
|
||||
public int Version { get; set; } = 6;
|
||||
public int Version { get; set; } = 7;
|
||||
|
||||
[Comment("""
|
||||
Most commands, when executed, have a small colored line
|
||||
@@ -52,6 +52,14 @@ public sealed partial class BotConfig : ICloneable<BotConfig>
|
||||
""")]
|
||||
public ulong? ForwardToChannel { get; set; }
|
||||
|
||||
[Comment("""
|
||||
Should the bot ignore messages from other bots?
|
||||
Settings this to false might get your bot banned if it gets into a spam loop with another bot.
|
||||
This will only affect command executions, other features will still block bots from access.
|
||||
Default true
|
||||
""")]
|
||||
public bool IgnoreOtherBots { get; set; }
|
||||
|
||||
[Comment("""
|
||||
When a user DMs the bot with a message which is not a command
|
||||
they will receive this message. Leave empty for no response. The string which will be sent whenever someone DMs the bot.
|
||||
|
@@ -23,7 +23,7 @@ public class CommandHandler : INService, IReadyExecutor, ICommandHandler
|
||||
|
||||
private readonly DiscordSocketClient _client;
|
||||
private readonly CommandService _commandService;
|
||||
private readonly BotConfigService _bss;
|
||||
private readonly BotConfigService _bcs;
|
||||
private readonly IBot _bot;
|
||||
private readonly IBehaviorHandler _behaviorHandler;
|
||||
private readonly IServiceProvider _services;
|
||||
@@ -31,13 +31,15 @@ public class CommandHandler : INService, IReadyExecutor, ICommandHandler
|
||||
private readonly ConcurrentDictionary<ulong, string> _prefixes;
|
||||
|
||||
private readonly DbService _db;
|
||||
|
||||
private readonly BotConfig _bc;
|
||||
// private readonly InteractionService _interactions;
|
||||
|
||||
public CommandHandler(
|
||||
DiscordSocketClient client,
|
||||
DbService db,
|
||||
CommandService commandService,
|
||||
BotConfigService bss,
|
||||
BotConfigService bcs,
|
||||
IBot bot,
|
||||
IBehaviorHandler behaviorHandler,
|
||||
// InteractionService interactions,
|
||||
@@ -45,7 +47,8 @@ public class CommandHandler : INService, IReadyExecutor, ICommandHandler
|
||||
{
|
||||
_client = client;
|
||||
_commandService = commandService;
|
||||
_bss = bss;
|
||||
_bc = bcs.Data;
|
||||
_bcs = bcs;
|
||||
_bot = bot;
|
||||
_behaviorHandler = behaviorHandler;
|
||||
_db = db;
|
||||
@@ -55,7 +58,6 @@ public class CommandHandler : INService, IReadyExecutor, ICommandHandler
|
||||
_prefixes = bot.AllGuildConfigs.Where(x => x.Prefix is not null)
|
||||
.ToDictionary(x => x.GuildId, x => x.Prefix)
|
||||
.ToConcurrent();
|
||||
|
||||
}
|
||||
|
||||
public async Task OnReadyAsync()
|
||||
@@ -72,7 +74,7 @@ public class CommandHandler : INService, IReadyExecutor, ICommandHandler
|
||||
public string GetPrefix(ulong? id = null)
|
||||
{
|
||||
if (id is null || !_prefixes.TryGetValue(id.Value, out var prefix))
|
||||
return _bss.Data.Prefix;
|
||||
return _bcs.Data.Prefix;
|
||||
|
||||
return prefix;
|
||||
}
|
||||
@@ -82,7 +84,7 @@ public class CommandHandler : INService, IReadyExecutor, ICommandHandler
|
||||
if (string.IsNullOrWhiteSpace(prefix))
|
||||
throw new ArgumentNullException(nameof(prefix));
|
||||
|
||||
_bss.ModifyConfig(bs =>
|
||||
_bcs.ModifyConfig(bs =>
|
||||
{
|
||||
bs.Prefix = prefix;
|
||||
});
|
||||
@@ -146,7 +148,7 @@ public class CommandHandler : INService, IReadyExecutor, ICommandHandler
|
||||
|
||||
private Task LogSuccessfulExecution(IUserMessage usrMsg, ITextChannel channel, params int[] execPoints)
|
||||
{
|
||||
if (_bss.Data.ConsoleOutputType == ConsoleOutputType.Normal)
|
||||
if (_bcs.Data.ConsoleOutputType == ConsoleOutputType.Normal)
|
||||
{
|
||||
Log.Information("""
|
||||
Command Executed after {ExecTime}s
|
||||
@@ -179,7 +181,7 @@ public class CommandHandler : INService, IReadyExecutor, ICommandHandler
|
||||
ITextChannel channel,
|
||||
params int[] execPoints)
|
||||
{
|
||||
if (_bss.Data.ConsoleOutputType == ConsoleOutputType.Normal)
|
||||
if (_bcs.Data.ConsoleOutputType == ConsoleOutputType.Normal)
|
||||
{
|
||||
Log.Warning("""
|
||||
Command Errored after {ExecTime}s
|
||||
@@ -212,8 +214,15 @@ public class CommandHandler : INService, IReadyExecutor, ICommandHandler
|
||||
|
||||
private Task MessageReceivedHandler(SocketMessage msg)
|
||||
{
|
||||
//no bots, wait until bot connected and initialized
|
||||
if (msg.Author.IsBot || !_bot.IsReady)
|
||||
if (!_bot.IsReady)
|
||||
return Task.CompletedTask;
|
||||
|
||||
if (_bc.IgnoreOtherBots)
|
||||
{
|
||||
if (msg.Author.IsBot)
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
else if (msg.Author.Id == _client.CurrentUser.Id)
|
||||
return Task.CompletedTask;
|
||||
|
||||
if (msg is not SocketUserMessage usrMsg)
|
||||
|
@@ -62,5 +62,12 @@ public sealed class BotConfigService : ConfigServiceBase<BotConfig>
|
||||
{
|
||||
c.Version = 5;
|
||||
});
|
||||
|
||||
if(data.Version < 7)
|
||||
ModifyConfig(c =>
|
||||
{
|
||||
c.Version = 7;
|
||||
c.IgnoreOtherBots = true;
|
||||
});
|
||||
}
|
||||
}
|
@@ -1,5 +1,5 @@
|
||||
# DO NOT CHANGE
|
||||
version: 5
|
||||
version: 7
|
||||
# Most commands, when executed, have a small colored line
|
||||
# next to the response. The color depends whether the command
|
||||
# is completed, errored or in progress (pending)
|
||||
@@ -28,6 +28,11 @@ forwardToAllOwners: false
|
||||
# Any messages sent by users in Bot's DM to be forwarded to the specified channel.
|
||||
# This option will only work when ForwardToAllOwners is set to false
|
||||
forwardToChannel:
|
||||
# Should the bot ignore messages from other bots?
|
||||
# Settings this to false might get your bot banned if it gets into a spam loop with another bot.
|
||||
# This will only affect command executions, other features will still block bots from access.
|
||||
# Default true
|
||||
ignoreOtherBots: true
|
||||
# When a user DMs the bot with a message which is not a command
|
||||
# they will receive this message. Leave empty for no response. The string which will be sent whenever someone DMs the bot.
|
||||
# Supports embeds. How it looks: https://puu.sh/B0BLV.png
|
||||
|
@@ -1,12 +1,12 @@
|
||||
# DO NOT CHANGE
|
||||
version: 6
|
||||
version: 7
|
||||
# Currency settings
|
||||
currency:
|
||||
# What is the emoji/character which represents the currency
|
||||
sign: "🌸"
|
||||
# What is the name of the currency
|
||||
name: Nadeko Flower
|
||||
# For how long will the transactions be kept in the database (curtrs)
|
||||
# For how long (in days) will the transactions be kept in the database (curtrs)
|
||||
# Set 0 to disable cleanup (keep transactions forever)
|
||||
transactionsLifetime: 0
|
||||
# Minimum amount users can bet (>=0)
|
||||
@@ -67,6 +67,14 @@ decay:
|
||||
minThreshold: 99
|
||||
# How often, in hours, does the decay run. Default is 24 hours
|
||||
hourInterval: 24
|
||||
# What is the bot's cut on some transactions
|
||||
botCuts:
|
||||
# Shop sale cut percentage.
|
||||
# Whenever a user buys something from the shop, bot will take a cut equal to this percentage.
|
||||
# The rest goes to the user who posted the item/role/whatever to the shop.
|
||||
# This is a good way to reduce the amount of currency in circulation therefore keeping the inflation in check.
|
||||
# Default 0.1 (10%).
|
||||
shopSaleCut: 0.1
|
||||
# Settings for LuckyLadder command
|
||||
luckyLadder:
|
||||
# Self-Explanatory. Has to have 8 values, otherwise the command won't work.
|
||||
|
Reference in New Issue
Block a user