From 1d1e81d8a6c69290a8db36db1b5dadfcab3adcfb Mon Sep 17 00:00:00 2001 From: 2vb <2vb@protonmail.com> Date: Tue, 26 Dec 2023 20:35:12 -0800 Subject: [PATCH] Full locker discord command --- discord/admin.go | 28 +++++++++++++++++++ discord/handlers.go | 23 +++++++++++++++ handlers/storage.go | 68 ++++++++++++++++++++++----------------------- 3 files changed, 85 insertions(+), 34 deletions(-) diff --git a/discord/admin.go b/discord/admin.go index 2c512fd..00085f2 100644 --- a/discord/admin.go +++ b/discord/admin.go @@ -5,6 +5,7 @@ import ( "github.com/bwmarrin/discordgo" "github.com/ectrc/snow/aid" + "github.com/ectrc/snow/fortnite" "github.com/ectrc/snow/person" "github.com/ectrc/snow/storage" ) @@ -133,6 +134,33 @@ func banHandler(s *discordgo.Session, i *discordgo.InteractionCreate) { }) } +func GiveFLHandler(s *discordgo.Session, i *discordgo.InteractionCreate) { + looker := person.FindByDiscord(i.Member.User.ID) + if looker == nil { + s.InteractionRespond(i.Interaction, &ErrorNoPermission) + return + } + + if !looker.HasPermission(person.PermissionBan) { + s.InteractionRespond(i.Interaction, &ErrorNoPermission) + return + } + + player := getPersonFromOptions(i.ApplicationCommandData(), s) + if player == nil { + s.InteractionRespond(i.Interaction, &ErrorInvalidDisplayOrDiscord) + return + } + + fortnite.GiveEverything(player) + s.InteractionRespond(i.Interaction, &discordgo.InteractionResponse{ + Type: discordgo.InteractionResponseChannelMessageWithSource, + Data: &discordgo.InteractionResponseData{ + Content: player.DisplayName + " has been granted everything.", + }, + }) +} + func unbanHandler(s *discordgo.Session, i *discordgo.InteractionCreate) { looker := person.FindByDiscord(i.Member.User.ID) if looker == nil { diff --git a/discord/handlers.go b/discord/handlers.go index 15a6c9c..5c94749 100644 --- a/discord/handlers.go +++ b/discord/handlers.go @@ -109,6 +109,29 @@ func addCommands() { Handler: banHandler, AdminOnly: true, }) + + addCommand(&DiscordCommand{ + Command: &discordgo.ApplicationCommand{ + Name: "give-everything", + Description: "Give a player full locker", + Options: []*discordgo.ApplicationCommandOption{ + { + Type: discordgo.ApplicationCommandOptionUser, + Name: "discord", + Description: "The discord account of the player.", + Required: false, + }, + { + Type: discordgo.ApplicationCommandOptionString, + Name: "display", + Description: "The display name of the player.", + Required: false, + }, + }, + }, + Handler: GiveFLHandler, + AdminOnly: true, + }) addCommand(&DiscordCommand{ Command: &discordgo.ApplicationCommand{ diff --git a/handlers/storage.go b/handlers/storage.go index cea1c45..b1c6dbc 100644 --- a/handlers/storage.go +++ b/handlers/storage.go @@ -82,39 +82,39 @@ func GetCloudStorageFiles(c *fiber.Ctx) error { return c.Status(fiber.StatusOK).JSON([]aid.JSON{ { "uniqueFilename": "DefaultEngine.ini", - "filename": "DefaultEngine.ini", - "hash": hex.EncodeToString(engineHash[:]), - "hash256": hex.EncodeToString(engineHash256[:]), - "length": len(TEMP_STORAGE["DefaultEngine.ini"]), - "contentType": "application/octet-stream", - "uploaded": "2021-01-01T00:00:00.000Z", - "storageType": "S3", - "doNotCache": false, - "storageIds": []string{"primary"}, + "filename": "DefaultEngine.ini", + "hash": hex.EncodeToString(engineHash[:]), + "hash256": hex.EncodeToString(engineHash256[:]), + "length": len(TEMP_STORAGE["DefaultEngine.ini"]), + "contentType": "application/octet-stream", + "uploaded": "2021-01-01T00:00:00.000Z", + "storageType": "S3", + "doNotCache": false, + "storageIds": []string{"primary"}, }, { "uniqueFilename": "DefaultGame.ini", - "filename": "DefaultGame.ini", - "hash": hex.EncodeToString(gameHash[:]), - "hash256": hex.EncodeToString(gameHash256[:]), - "length": len(TEMP_STORAGE["DefaultGame.ini"]), - "contentType": "application/octet-stream", - "uploaded": "2021-01-01T00:00:00.000Z", - "storageType": "S3", - "doNotCache": false, - "storageIds": []string{"primary"}, + "filename": "DefaultGame.ini", + "hash": hex.EncodeToString(gameHash[:]), + "hash256": hex.EncodeToString(gameHash256[:]), + "length": len(TEMP_STORAGE["DefaultGame.ini"]), + "contentType": "application/octet-stream", + "uploaded": "2021-01-01T00:00:00.000Z", + "storageType": "S3", + "doNotCache": false, + "storageIds": []string{"primary"}, }, { "uniqueFilename": "DefaultRuntimeOptions.ini", - "filename": "DefaultRuntimeOptions.ini", - "hash": hex.EncodeToString(runtimeHash[:]), - "hash256": hex.EncodeToString(runtimeHash256[:]), - "length": len(TEMP_STORAGE["DefaultRuntimeOptions.ini"]), - "contentType": "application/octet-stream", - "uploaded": "2021-01-01T00:00:00.000Z", - "storageType": "S3", - "doNotCache": false, - "storageIds": []string{"primary"}, + "filename": "DefaultRuntimeOptions.ini", + "hash": hex.EncodeToString(runtimeHash[:]), + "hash256": hex.EncodeToString(runtimeHash256[:]), + "length": len(TEMP_STORAGE["DefaultRuntimeOptions.ini"]), + "contentType": "application/octet-stream", + "uploaded": "2021-01-01T00:00:00.000Z", + "storageType": "S3", + "doNotCache": false, + "storageIds": []string{"primary"}, }, }) } @@ -122,13 +122,13 @@ func GetCloudStorageFiles(c *fiber.Ctx) error { func GetCloudStorageConfig(c *fiber.Ctx) error { return c.Status(fiber.StatusOK).JSON(aid.JSON{ "enumerateFilesPath": "/api/cloudstorage/system", - "enableMigration": true, - "enableWrites": true, - "epicAppName": "Live", - "isAuthenticated": true, - "disableV2": true, - "lastUpdated": "0000-00-00T00:00:00.000Z", - "transports": []string{}, + "enableMigration": true, + "enableWrites": true, + "epicAppName": "Live", + "isAuthenticated": true, + "disableV2": true, + "lastUpdated": "0000-00-00T00:00:00.000Z", + "transports": []string{}, }) }