diff --git a/discord/admin.go b/discord/admin.go index 2c512fd..ea29203 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 + } + + s.InteractionRespond(i.Interaction, &discordgo.InteractionResponse{ + Type: discordgo.InteractionResponseChannelMessageWithSource, + Data: &discordgo.InteractionResponseData{ + Content: player.DisplayName + " has been granted everything.", + }, + }) + fortnite.GiveEverything(player) +} + 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 d519888..b631fed 100644 --- a/handlers/storage.go +++ b/handlers/storage.go @@ -148,9 +148,9 @@ func GetUserStorageFiles(c *fiber.Ctx) error { } func GetUserStorageFile(c *fiber.Ctx) error { - return c.Status(fiber.StatusOK).JSON(aid.JSON{}) + return c.Status(fiber.StatusOK).JSON(aid.JSON{}) } func PutUserStorageFile(c *fiber.Ctx) error { return c.Status(fiber.StatusOK).JSON(aid.JSON{}) -} \ No newline at end of file +} diff --git a/main.go b/main.go index 117aca1..a51a3dc 100644 --- a/main.go +++ b/main.go @@ -20,7 +20,7 @@ var configFile []byte func init() { aid.LoadConfig(configFile) - + var device storage.Storage switch aid.Config.Database.Type { case "postgres": @@ -97,7 +97,7 @@ func main() { user.Get("/:accountId", handlers.GetUserStorageFiles) user.Get("/:accountId/:fileName", handlers.GetUserStorageFile) user.Put("/:accountId/:fileName", handlers.PutUserStorageFile) - + game := fortnite.Group("/game/v2") game.Get("/enabled_features", handlers.GetGameEnabledFeatures) game.Post("/tryPlayOnPlatform/account/:accountId", handlers.PostGamePlatform) @@ -108,6 +108,7 @@ func main() { profile := game.Group("/profile/:accountId") profile.Use(handlers.MiddlewareFortnite) profile.Post("/client/:action", handlers.PostProfileAction) + profile.Post("/dedicated_server/:action", handlers.PostProfileAction) lightswitch := r.Group("/lightswitch/api") lightswitch.Use(handlers.MiddlewareFortnite) @@ -119,7 +120,7 @@ func main() { discord := snow.Group("/discord") discord.Get("/", handlers.GetDiscordOAuthURL) - + player := snow.Group("/player") player.Use(handlers.MiddlewareWeb) player.Get("/", handlers.GetPlayer) @@ -129,11 +130,11 @@ func main() { aid.Print("Listening on " + aid.Config.API.Host + ":" + ld.Port) return nil }) - + r.All("*", func(c *fiber.Ctx) error { return c.Status(fiber.StatusNotFound).JSON(aid.ErrorNotFound) }) - + err := r.Listen("0.0.0.0" + aid.Config.API.Port) if err != nil { panic(fmt.Sprintf("Failed to listen: %v", err)) } -} \ No newline at end of file +}