From e9eb6ff2ad74a74c9925ed2893591b1cef19b1bc Mon Sep 17 00:00:00 2001 From: Kwoth Date: Thu, 11 Aug 2022 14:39:44 +0200 Subject: [PATCH] Added '.bank take' owner only command --- .../Modules/Gambling/Bank/BankCommands.cs | 32 ++++++++++++++++++- src/NadekoBot/data/aliases.yml | 3 ++ .../data/strings/commands/commands.en-US.yml | 4 +++ 3 files changed, 38 insertions(+), 1 deletion(-) diff --git a/src/NadekoBot/Modules/Gambling/Bank/BankCommands.cs b/src/NadekoBot/Modules/Gambling/Bank/BankCommands.cs index 75f7f2f8d..306c08953 100644 --- a/src/NadekoBot/Modules/Gambling/Bank/BankCommands.cs +++ b/src/NadekoBot/Modules/Gambling/Bank/BankCommands.cs @@ -11,10 +11,14 @@ public partial class Gambling public partial class BankCommands : GamblingModule { private readonly IBankService _bank; + private readonly DiscordSocketClient _client; - public BankCommands(GamblingConfigService gcs, IBankService bank) : base(gcs) + public BankCommands(GamblingConfigService gcs, + IBankService bank, + DiscordSocketClient client) : base(gcs) { _bank = bank; + _client = client; } [Cmd] @@ -68,5 +72,31 @@ public partial class Gambling await ReplyErrorLocalizedAsync(strs.cant_dm); } } + + private async Task BankTakeInternalAsync(long amount, ulong userId) + { + if (await _bank.WithdrawAsync(userId, amount)) + { + await ReplyErrorLocalizedAsync(strs.take_fail(N(amount), + _client.GetUser(userId)?.ToString() + ?? userId.ToString(), + CurrencySign)); + return; + } + + await ctx.OkAsync(); + } + + [Cmd] + [OwnerOnly] + [Priority(-1)] + public async Task BankTake(long amount, [Leftover] IUser user) + => await BankTakeInternalAsync(amount, user.Id); + + [Cmd] + [OwnerOnly] + [Priority(0)] + public async Task BankTake(long amount, ulong userId) + => await BankTakeInternalAsync(amount, userId); } } \ No newline at end of file diff --git a/src/NadekoBot/data/aliases.yml b/src/NadekoBot/data/aliases.yml index 8c2d94561..93c732690 100644 --- a/src/NadekoBot/data/aliases.yml +++ b/src/NadekoBot/data/aliases.yml @@ -1308,6 +1308,7 @@ medusalist: medusainfo: - medusainfo - meinfo +# Bank stuff bankdeposit: - deposit - d @@ -1320,6 +1321,8 @@ bankbalance: - balance - b - bal +banktake: + - take # Patron patron: - patron diff --git a/src/NadekoBot/data/strings/commands/commands.en-US.yml b/src/NadekoBot/data/strings/commands/commands.en-US.yml index 86e5298ec..d5a71b399 100644 --- a/src/NadekoBot/data/strings/commands/commands.en-US.yml +++ b/src/NadekoBot/data/strings/commands/commands.en-US.yml @@ -2237,6 +2237,10 @@ bankbalance: desc: "Shows your current bank balance available for withdrawal." args: - "" +banktake: + desc: "Takes the specified from a user's bank" + args: + - "500 @MoniLaunder" patron: desc: "Check your patronage status and command usage quota. Bot owners can check targeted user's patronage status." args: