diff --git a/Bot/Admin.fs b/Bot/Admin.fs index fa28004..e431416 100644 --- a/Bot/Admin.fs +++ b/Bot/Admin.fs @@ -125,6 +125,35 @@ let getUserInvites userIds = |> Sql.executeAsync (fun read -> {| Username = read.string "display_name" ; DiscordId = read.string "inviter" |> uint64 ; TotalInvites = read.int "total_invites" |}) |> Async.AwaitTask +type MerrisItem = + | NuuPing = 0 + | Noodles = 1 + | Pizza = 2 + +let updateMerrisItem itemName amount = + let itemId = + match itemName with + | MerrisItem.Noodles -> "NOODLES" + | MerrisItem.Pizza -> "PIZZA" + | MerrisItem.NuuPing | _ -> "GRILLED_RAT" + + GuildEnvironment.connectionString + |> Sql.connect + |> Sql.parameters [ "itemId" , Sql.string itemId ; "amount" , Sql.int amount ] + |> Sql.query "UPDATE mart_item SET stock = @amount WHERE id = @itemId" + |> Sql.executeNonQueryAsync + |> Async.AwaitTask + +let restockMerris itemName amount (ctx : IDiscordContext) = + task { + do! Messaging.defer ctx + if amount > 0 && amount < 1000 then + do! updateMerrisItem itemName amount |> Async.Ignore + do! Messaging.sendSimpleResponse ctx $"Restocked {itemName} by {amount}" + else + do! Messaging.sendSimpleResponse ctx $"Provide a restock amount between 0 and 1000" + } :> Task + let getUsersFromMessageReactions (channel : DiscordChannel) (message : string) (ctx : IDiscordContext) = task { do! Messaging.defer ctx @@ -246,6 +275,13 @@ type AdminBot() = else Messaging.sendSimpleResponse ctx $"You are not admin" |> Async.StartAsTask :> Task + let enforceMod (ctx : IDiscordContext) (modFn : IDiscordContext -> Task) = + let isMod = Seq.exists (fun (role : DiscordRole) -> role.Id = 941379834163109978uL) (ctx.GetDiscordMember().Roles) + if isMod then + modFn ctx + else + Messaging.sendSimpleResponse ctx $"You are not a mod" |> Async.StartAsTask :> Task + [] [] member this.GetAttributions (ctx : InteractionContext, [] user : DiscordUser) = @@ -284,6 +320,12 @@ type AdminBot() = member this.GetRaffleWinners (ctx : InteractionContext, [] count : int64) = enforceAdmin (DiscordInteractionContext ctx) (getRaffleWinners count) + [] + member this.ResstockMerris (ctx : InteractionContext, + [] itemId : MerrisItem, + [] amount : int64) = + enforceAdmin (DiscordInteractionContext ctx) (restockMerris itemId (int amount)) + // [] // member this.ToggleRaffle (ctx : InteractionContext, [] enable : EnableDisable) = // enforceAdmin (DiscordInteractionContext ctx) (toggleRaffleAvailability (enable = EnableDisable.Enable)) diff --git a/Bot/GuildEnvironment.fs b/Bot/GuildEnvironment.fs index 4f8da18..97dcad4 100644 --- a/Bot/GuildEnvironment.fs +++ b/Bot/GuildEnvironment.fs @@ -59,6 +59,7 @@ let roleWhitelistPending = getId "ROLE_WHITELIST_PENDING" let roleWhiteOGPending = getId "ROLE_WHITEOG_PENDING" let roleWhitelist = getId "ROLE_WHITELIST" let roleWhiteOG = getId "ROLE_WHITEOG" +// let roleMod = getId "ROLE_MOD" let roleAdmin = getId "ROLE_ADMIN" let roleMagicEden = getId "ROLE_MAGICEDEN" let roleRecruiter1x = getId "ROLE_RECRUITER_1X" diff --git a/paket.dependencies b/paket.dependencies index 8c05677..0c953bf 100644 --- a/paket.dependencies +++ b/paket.dependencies @@ -5,13 +5,12 @@ framework: net6.0, netstandard2.0, netstandard2.1 nuget FSharp.Core >= 6.0.0 -nuget DSharpPlus >= 4.3.0-nightly-01135 -nuget DSharpPlus.Interactivity >= 4.3.0-nightly-01135 -nuget DSharpPlus.SlashCommands >= 4.3.0-nightly-01135 +nuget DSharpPlus >= 4.3.0-nightly-01160 +nuget DSharpPlus.Interactivity >= 4.3.0-nightly-01160 +nuget DSharpPlus.SlashCommands >= 4.3.0-nightly-01160 nuget FSharp.Data nuget FsToolkit.ErrorHandling -nuget MongoDB.Driver nuget dotenv.net 3.1.1 nuget Npgsql.FSharp nuget mixpanel-csharp 5.0.0 diff --git a/paket.lock b/paket.lock index 15b27e4..a834e89 100644 --- a/paket.lock +++ b/paket.lock @@ -4,12 +4,9 @@ NUGET remote: https://api.nuget.org/v3/index.json Chaos.NaCl.Standard (1.0) - restriction: || (== net6.0) (&& (== netstandard2.0) (>= net6.0)) (&& (== netstandard2.1) (>= net6.0)) ConcurrentHashSet (1.3) - DnsClient (1.6) - Microsoft.Win32.Registry (>= 5.0) - System.Buffers (>= 4.5.1) - restriction: || (&& (== net6.0) (>= net471)) (&& (== net6.0) (< netstandard2.0)) (&& (== net6.0) (< netstandard2.1)) (== netstandard2.0) (&& (== netstandard2.1) (>= net471)) (&& (== netstandard2.1) (< netstandard2.0)) dotenv.net (3.1.1) System.Memory (>= 4.5.4) - restriction: || (&& (== net6.0) (< netstandard2.0)) (&& (== net6.0) (< netstandard2.1)) (== netstandard2.0) (&& (== netstandard2.1) (< netstandard2.0)) - DSharpPlus (4.3.0-nightly-01135) + DSharpPlus (4.3.0-nightly-01160) Emzi0767.Common (>= 2.6.2) Microsoft.Extensions.Logging.Abstractions (>= 5.0) Newtonsoft.Json (>= 13.0.1) @@ -19,25 +16,22 @@ NUGET System.Net.WebSockets.Client (>= 4.3.2) System.Runtime.InteropServices.RuntimeInformation (>= 4.3) System.Threading.Channels (>= 5.0) - DSharpPlus.Interactivity (4.3.0-nightly-01135) + DSharpPlus.Interactivity (4.3.0-nightly-01160) ConcurrentHashSet (>= 1.1) - DSharpPlus (>= 4.3.0-nightly-01135) - DSharpPlus.SlashCommands (4.3.0-nightly-01135) - DSharpPlus (>= 4.3.0-nightly-01135) + DSharpPlus (>= 4.3.0-nightly-01160) + DSharpPlus.SlashCommands (4.3.0-nightly-01160) + DSharpPlus (>= 4.3.0-nightly-01160) Microsoft.Extensions.DependencyInjection (>= 5.0.1) - Emzi0767.Common (2.6.2) - System.Collections.Immutable (>= 5.0) - System.Memory (>= 4.5.4) - System.Runtime.CompilerServices.Unsafe (>= 5.0) - System.ValueTuple (>= 4.5) - FSharp.Core (6.0.3) - FSharp.Data (4.2.8) - FSharp.Core (>= 4.7.2) + Emzi0767.Common (2.6.6) + System.Collections.Immutable (>= 6.0) + System.Runtime.CompilerServices.Unsafe (>= 6.0) + FSharp.Core (6.0.5) + FSharp.Data (4.2.9) + FSharp.Core (>= 5.0.1) FsToolkit.ErrorHandling (2.13) FSharp.Core (>= 4.7.2) - Microsoft.Bcl.AsyncInterfaces (6.0) - restriction: || (&& (== net6.0) (< netstandard2.1)) (== netstandard2.0) + Microsoft.Bcl.AsyncInterfaces (6.0) - restriction: || (&& (== net6.0) (>= net461)) (&& (== net6.0) (< netstandard2.1)) (== netstandard2.0) (&& (== netstandard2.1) (>= net461)) System.Threading.Tasks.Extensions (>= 4.5.4) - restriction: || (&& (== net6.0) (>= net461)) (&& (== net6.0) (< netstandard2.1)) (== netstandard2.0) (&& (== netstandard2.1) (>= net461)) - Microsoft.Bcl.HashCode (1.1.1) - restriction: || (&& (== net6.0) (< netstandard2.1)) (== netstandard2.0) Microsoft.Extensions.Configuration (6.0.1) - restriction: || (== net6.0) (&& (== netstandard2.0) (>= net6.0)) (&& (== netstandard2.1) (>= net6.0)) Microsoft.Extensions.Configuration.Abstractions (>= 6.0) Microsoft.Extensions.Primitives (>= 6.0) @@ -89,50 +83,19 @@ NUGET Microsoft.Extensions.Primitives (>= 6.0) Microsoft.Extensions.Primitives (6.0) - restriction: || (== net6.0) (&& (== netstandard2.0) (>= net6.0)) (&& (== netstandard2.1) (>= net6.0)) System.Runtime.CompilerServices.Unsafe (>= 6.0) - Microsoft.NETCore.Platforms (6.0.2) + Microsoft.NETCore.Platforms (6.0.5) Microsoft.NETCore.Targets (5.0) Microsoft.Win32.Primitives (4.3) Microsoft.NETCore.Platforms (>= 1.1) Microsoft.NETCore.Targets (>= 1.1) System.Runtime (>= 4.3) - Microsoft.Win32.Registry (5.0) - System.Buffers (>= 4.5.1) - restriction: || (&& (== net6.0) (>= monoandroid) (< netstandard1.3)) (&& (== net6.0) (>= monotouch)) (&& (== net6.0) (< netcoreapp2.0)) (&& (== net6.0) (>= xamarinios)) (&& (== net6.0) (>= xamarinmac)) (&& (== net6.0) (>= xamarintvos)) (&& (== net6.0) (>= xamarinwatchos)) (== netstandard2.0) (== netstandard2.1) - System.Memory (>= 4.5.4) - restriction: || (&& (== net6.0) (< netcoreapp2.0)) (&& (== net6.0) (< netcoreapp2.1)) (&& (== net6.0) (>= uap10.1)) (== netstandard2.0) (== netstandard2.1) - System.Security.AccessControl (>= 5.0) - System.Security.Principal.Windows (>= 5.0) mixpanel-csharp (5.0) - MongoDB.Bson (2.15) - System.Runtime.CompilerServices.Unsafe (>= 5.0) - MongoDB.Driver (2.15) - MongoDB.Bson (>= 2.15) - MongoDB.Driver.Core (>= 2.15) - MongoDB.Libmongocrypt (>= 1.3) - MongoDB.Driver.Core (2.15) - DnsClient (>= 1.6) - MongoDB.Bson (>= 2.15) - MongoDB.Libmongocrypt (>= 1.3) - SharpCompress (>= 0.30.1) - System.Buffers (>= 4.5.1) - MongoDB.Libmongocrypt (1.3) Newtonsoft.Json (13.0.1) - Npgsql (6.0.3) - Microsoft.Bcl.AsyncInterfaces (>= 6.0) - restriction: || (&& (== net6.0) (< netstandard2.1)) (== netstandard2.0) - Microsoft.Bcl.HashCode (>= 1.1.1) - restriction: || (&& (== net6.0) (< netstandard2.1)) (== netstandard2.0) - System.Collections.Immutable (>= 6.0) - restriction: || (&& (== net6.0) (< netcoreapp3.1)) (&& (== net6.0) (< netstandard2.1)) (== netstandard2.0) (== netstandard2.1) - System.Diagnostics.DiagnosticSource (>= 6.0) - restriction: || (&& (== net6.0) (< net5.0)) (&& (== net6.0) (< netcoreapp3.1)) (&& (== net6.0) (< netstandard2.1)) (== netstandard2.0) (== netstandard2.1) - System.Memory (>= 4.5.4) - restriction: || (&& (== net6.0) (< netstandard2.1)) (== netstandard2.0) + Npgsql (6.0.5) - restriction: || (== net6.0) (&& (== netstandard2.0) (>= net6.0)) (&& (== netstandard2.1) (>= net6.0)) System.Runtime.CompilerServices.Unsafe (>= 6.0) - System.Text.Json (>= 6.0) - restriction: || (&& (== net6.0) (< netcoreapp3.1)) (&& (== net6.0) (< netstandard2.1)) (== netstandard2.0) (== netstandard2.1) - System.Threading.Channels (>= 6.0) - restriction: || (&& (== net6.0) (< netcoreapp3.1)) (&& (== net6.0) (< netstandard2.1)) (== netstandard2.0) (== netstandard2.1) - System.Threading.Tasks.Extensions (>= 4.5.4) - restriction: || (&& (== net6.0) (< netstandard2.1)) (== netstandard2.0) - System.ValueTuple (>= 4.5) - restriction: || (&& (== net6.0) (< netstandard2.1)) (== netstandard2.0) - Npgsql.FSharp (4.1) - FSharp.Core (>= 4.7.2) - Npgsql (>= 5.0.3) - Ply (>= 0.3.1) - Ply (0.3.1) - FSharp.Core (>= 4.6.2) - System.Threading.Tasks.Extensions (>= 4.5.4) + Npgsql.FSharp (5.2) + FSharp.Core (>= 6.0.2) - restriction: || (== net6.0) (&& (== netstandard2.0) (>= net6.0)) (&& (== netstandard2.1) (>= net6.0)) + Npgsql (>= 6.0.5) - restriction: || (== net6.0) (&& (== netstandard2.0) (>= net6.0)) (&& (== netstandard2.1) (>= net6.0)) Portable.BouncyCastle (1.9) - restriction: || (== net6.0) (&& (== netstandard2.0) (>= net6.0)) (&& (== netstandard2.1) (>= net6.0)) runtime.debian.8-x64.runtime.native.System.Security.Cryptography.OpenSsl (4.3.3) runtime.debian.9-x64.runtime.native.System.Security.Cryptography.OpenSsl (4.3.3) @@ -177,27 +140,24 @@ NUGET runtime.ubuntu.16.04-x64.runtime.native.System.Security.Cryptography.OpenSsl (4.3.3) runtime.ubuntu.16.10-x64.runtime.native.System.Security.Cryptography.OpenSsl (4.3.3) runtime.ubuntu.18.04-x64.runtime.native.System.Security.Cryptography.OpenSsl (4.3.3) - SharpCompress (0.30.1) - System.Memory (>= 4.5.4) - restriction: || (&& (== net6.0) (>= net461)) (&& (== net6.0) (< netstandard2.1)) (== netstandard2.0) (&& (== netstandard2.1) (>= net461)) - System.Text.Encoding.CodePages (>= 5.0) - restriction: || (&& (== net6.0) (>= net461)) (&& (== net6.0) (< netcoreapp3.1)) (&& (== net6.0) (< netstandard2.1)) (== netstandard2.0) (== netstandard2.1) - Solnet.Extensions (6.0.11) - Solnet.Programs (>= 6.0.11) - restriction: || (== net6.0) (&& (== netstandard2.0) (>= net6.0)) (&& (== netstandard2.1) (>= net6.0)) - Solnet.Rpc (>= 6.0.11) - restriction: || (== net6.0) (&& (== netstandard2.0) (>= net6.0)) (&& (== netstandard2.1) (>= net6.0)) - Solnet.Wallet (>= 6.0.11) - restriction: || (== net6.0) (&& (== netstandard2.0) (>= net6.0)) (&& (== netstandard2.1) (>= net6.0)) - Solnet.KeyStore (6.0.11) + Solnet.Extensions (6.1) + Solnet.Programs (>= 6.1) - restriction: || (== net6.0) (&& (== netstandard2.0) (>= net6.0)) (&& (== netstandard2.1) (>= net6.0)) + Solnet.Rpc (>= 6.1) - restriction: || (== net6.0) (&& (== netstandard2.0) (>= net6.0)) (&& (== netstandard2.1) (>= net6.0)) + Solnet.Wallet (>= 6.1) - restriction: || (== net6.0) (&& (== netstandard2.0) (>= net6.0)) (&& (== netstandard2.1) (>= net6.0)) + Solnet.KeyStore (6.1) Chaos.NaCl.Standard (>= 1.0) - restriction: || (== net6.0) (&& (== netstandard2.0) (>= net6.0)) (&& (== netstandard2.1) (>= net6.0)) Portable.BouncyCastle (>= 1.9) - restriction: || (== net6.0) (&& (== netstandard2.0) (>= net6.0)) (&& (== netstandard2.1) (>= net6.0)) - Solnet.Wallet (>= 6.0.11) - restriction: || (== net6.0) (&& (== netstandard2.0) (>= net6.0)) (&& (== netstandard2.1) (>= net6.0)) - Solnet.Programs (6.0.11) - Solnet.Rpc (>= 6.0.11) - restriction: || (== net6.0) (&& (== netstandard2.0) (>= net6.0)) (&& (== netstandard2.1) (>= net6.0)) - Solnet.Rpc (6.0.11) + Solnet.Wallet (>= 6.1) - restriction: || (== net6.0) (&& (== netstandard2.0) (>= net6.0)) (&& (== netstandard2.1) (>= net6.0)) + Solnet.Programs (6.1) + Solnet.Rpc (>= 6.1) - restriction: || (== net6.0) (&& (== netstandard2.0) (>= net6.0)) (&& (== netstandard2.1) (>= net6.0)) + Solnet.Rpc (6.1) Microsoft.Extensions.Logging (>= 6.0) - restriction: || (== net6.0) (&& (== netstandard2.0) (>= net6.0)) (&& (== netstandard2.1) (>= net6.0)) Microsoft.Extensions.Logging.Console (>= 6.0) - restriction: || (== net6.0) (&& (== netstandard2.0) (>= net6.0)) (&& (== netstandard2.1) (>= net6.0)) - Solnet.Wallet (>= 6.0.11) - restriction: || (== net6.0) (&& (== netstandard2.0) (>= net6.0)) (&& (== netstandard2.1) (>= net6.0)) - Solnet.Wallet (6.0.11) - restriction: || (== net6.0) (&& (== netstandard2.0) (>= net6.0)) (&& (== netstandard2.1) (>= net6.0)) + Solnet.Wallet (>= 6.1) - restriction: || (== net6.0) (&& (== netstandard2.0) (>= net6.0)) (&& (== netstandard2.1) (>= net6.0)) + Solnet.Wallet (6.1) - restriction: || (== net6.0) (&& (== netstandard2.0) (>= net6.0)) (&& (== netstandard2.1) (>= net6.0)) Chaos.NaCl.Standard (>= 1.0) - restriction: || (== net6.0) (&& (== netstandard2.0) (>= net6.0)) (&& (== netstandard2.1) (>= net6.0)) Portable.BouncyCastle (>= 1.9) - restriction: || (== net6.0) (&& (== netstandard2.0) (>= net6.0)) (&& (== netstandard2.1) (>= net6.0)) - System.Buffers (4.5.1) + System.Buffers (4.5.1) - restriction: || (&& (== net6.0) (>= monotouch)) (&& (== net6.0) (>= net461)) (&& (== net6.0) (< netcoreapp2.0) (< netstandard2.1)) (&& (== net6.0) (< netstandard1.1)) (&& (== net6.0) (< netstandard2.0)) (&& (== net6.0) (< netstandard2.1) (>= xamarinios)) (&& (== net6.0) (< netstandard2.1) (>= xamarinmac)) (&& (== net6.0) (< netstandard2.1) (>= xamarintvos)) (&& (== net6.0) (< netstandard2.1) (>= xamarinwatchos)) (== netstandard2.0) (== netstandard2.1) System.Collections (4.3) Microsoft.NETCore.Platforms (>= 1.1) Microsoft.NETCore.Targets (>= 1.1) @@ -266,7 +226,7 @@ NUGET System.Resources.ResourceManager (>= 4.3) System.Runtime (>= 4.3) System.Runtime.Extensions (>= 4.3) - System.Memory (4.5.4) + System.Memory (4.5.5) System.Buffers (>= 4.5.1) - restriction: || (&& (== net6.0) (>= monotouch)) (&& (== net6.0) (>= net461)) (&& (== net6.0) (< netcoreapp2.0)) (&& (== net6.0) (< netstandard1.1)) (&& (== net6.0) (< netstandard2.0)) (&& (== net6.0) (>= xamarinios)) (&& (== net6.0) (>= xamarinmac)) (&& (== net6.0) (>= xamarintvos)) (&& (== net6.0) (>= xamarinwatchos)) (== netstandard2.0) (== netstandard2.1) System.Numerics.Vectors (>= 4.4) - restriction: || (&& (== net6.0) (< netcoreapp2.0)) (== netstandard2.0) (== netstandard2.1) System.Runtime.CompilerServices.Unsafe (>= 4.5.3) - restriction: || (&& (== net6.0) (>= monotouch)) (&& (== net6.0) (>= net461)) (&& (== net6.0) (< netcoreapp2.0)) (&& (== net6.0) (< netcoreapp2.1)) (&& (== net6.0) (< netstandard1.1)) (&& (== net6.0) (< netstandard2.0)) (&& (== net6.0) (>= uap10.1)) (&& (== net6.0) (>= xamarinios)) (&& (== net6.0) (>= xamarinmac)) (&& (== net6.0) (>= xamarintvos)) (&& (== net6.0) (>= xamarinwatchos)) (== netstandard2.0) (== netstandard2.1) @@ -444,8 +404,6 @@ NUGET System.Resources.ResourceManager (>= 4.3) System.Runtime (>= 4.3) System.Runtime.Extensions (>= 4.3) - System.Security.AccessControl (6.0) - System.Security.Principal.Windows (>= 5.0) - restriction: || (&& (== net6.0) (>= net461)) (== netstandard2.0) (== netstandard2.1) System.Security.Claims (4.3) System.Collections (>= 4.3) System.Globalization (>= 4.3) @@ -541,9 +499,6 @@ NUGET Microsoft.NETCore.Platforms (>= 1.1) Microsoft.NETCore.Targets (>= 1.1) System.Runtime (>= 4.3) - System.Text.Encoding.CodePages (6.0) - restriction: || (&& (== net6.0) (>= net461)) (&& (== net6.0) (< netcoreapp3.1)) (&& (== net6.0) (< netstandard2.1)) (== netstandard2.0) (== netstandard2.1) - System.Memory (>= 4.5.4) - restriction: || (&& (== net6.0) (>= net461)) (&& (== net6.0) (< netcoreapp3.1)) (== netstandard2.0) (== netstandard2.1) - System.Runtime.CompilerServices.Unsafe (>= 6.0) System.Text.Encoding.Extensions (4.3) Microsoft.NETCore.Platforms (>= 1.1) Microsoft.NETCore.Targets (>= 1.1) @@ -551,7 +506,7 @@ NUGET System.Text.Encoding (>= 4.3) System.Text.Encodings.Web (6.0) - restriction: || (== net6.0) (&& (== netstandard2.0) (>= net6.0)) (&& (== netstandard2.1) (>= net6.0)) System.Runtime.CompilerServices.Unsafe (>= 6.0) - System.Text.Json (6.0.2) + System.Text.Json (6.0.5) - restriction: || (== net6.0) (&& (== netstandard2.0) (>= net6.0)) (&& (== netstandard2.1) (>= net6.0)) System.Runtime.CompilerServices.Unsafe (>= 6.0) System.Text.Encodings.Web (>= 6.0) System.Threading (4.3) @@ -563,7 +518,7 @@ NUGET Microsoft.NETCore.Platforms (>= 1.1) Microsoft.NETCore.Targets (>= 1.1) System.Runtime (>= 4.3) - System.Threading.Tasks.Extensions (4.5.4) + System.Threading.Tasks.Extensions (4.5.4) - restriction: || (&& (== net6.0) (>= net461)) (&& (== net6.0) (< netstandard2.1)) (== netstandard2.0) (&& (== netstandard2.1) (>= net461)) System.Runtime.CompilerServices.Unsafe (>= 4.5.3) - restriction: || (&& (== net6.0) (>= net461)) (&& (== net6.0) (< netcoreapp2.1)) (&& (== net6.0) (< netstandard1.0)) (&& (== net6.0) (< netstandard2.0)) (&& (== net6.0) (>= wp8)) (== netstandard2.0) (== netstandard2.1) System.Threading.ThreadPool (4.3) System.Runtime (>= 4.3) @@ -572,4 +527,3 @@ NUGET Microsoft.NETCore.Platforms (>= 1.1) Microsoft.NETCore.Targets (>= 1.1) System.Runtime (>= 4.3) - System.ValueTuple (4.5)