diff --git a/data/lang/de.yaml b/data/lang/de.yaml index 2f67ffb..7696201 100644 --- a/data/lang/de.yaml +++ b/data/lang/de.yaml @@ -137,10 +137,17 @@ discord.command: msg.setup.success: Einladungen wurden verschickt! msg.invite.title: Einladung zum Wichteln. + msg.invite.description: Du nimmst am Cake4Everyone Wichteln teil. Klicke die Knöpfe unten, um deinen Partner zu sehen und deine Adresse einzutragen. + msg.invite.set_address.match: Dein Partner hat eine Adresse eingetragen + msg.invite.set_address: Deine Adresse wurde eingetragen msg.invite.button.show_match: Partner anzeigen msg.invite.button.set_address: Deine Adresse eintragen msg.invite.button.show_address: Adresse deines Partners anzeigen + msg.invite.modal.set_address.title: Deine Adresse eintragen + msg.invite.modal.set_address.label: Deine Adresse wird deinem Wichtel angezeigt + msg.invite.modal.set_address.placeholder: "Max Mustermann\nMusterstraße 1\n12345 Musterstadt" + module: adventcalendar: post.message: Noch %d Mal schlafen bis Heilig Abend! Heute öffnet sich das **Türchen %d**. diff --git a/data/lang/en.yaml b/data/lang/en.yaml index edb4512..15f7178 100644 --- a/data/lang/en.yaml +++ b/data/lang/en.yaml @@ -137,10 +137,17 @@ discord.command: msg.setup.success: Invites sent! msg.invite.title: Invite for secret santa. - msg.invite.button.show_match: Show match + msg.invite.description: You are participating in Cake4Everyone Secret Santa. Click the buttons below to see your partner and set your address. + msg.invite.set_address.match: Your partner has set an address + msg.invite.set_address: Your address is set + msg.invite.button.show_match: Show partner msg.invite.button.set_address: Set your address msg.invite.button.show_address: Show your partners address + msg.invite.modal.set_address.title: Set your address + msg.invite.modal.set_address.label: Your address will be shown your secret santa + msg.invite.modal.set_address.placeholder: "Mr. John Doe\n123 Main Street\nAnytown, USA 12345" + module: adventcalendar: post.message: Just sleep %d more times! Its time for **door %d**. diff --git a/modules/secretsanta/handleComponentInvite.go b/modules/secretsanta/handleComponentInvite.go index cfb8f3f..f4010b3 100644 --- a/modules/secretsanta/handleComponentInvite.go +++ b/modules/secretsanta/handleComponentInvite.go @@ -1,6 +1,7 @@ package secretsanta import ( + "cake4everybot/data/lang" "cake4everybot/util" "github.com/bwmarrin/discordgo" @@ -49,7 +50,41 @@ func (c Component) handleInviteShowMatch(ids []string) { } func (c Component) handleInviteSetAddress(ids []string) { + c.Interaction.GuildID = util.ShiftL(ids) + players, err := c.getPlayers() + if err != nil { + log.Printf("ERROR: could not get players: %+v", err) + c.ReplyError() + return + } + if len(players) == 0 { + log.Printf("ERROR: no players in guild %s", c.Interaction.GuildID) + c.ReplyError() + return + } + + var player *player + for _, p := range players { + if p.User.ID == c.Interaction.User.ID { + player = p + } + } + if player == nil { + log.Printf("ERROR: could not find player %s in guild %s: %+v", c.Interaction.User.ID, c.Interaction.GuildID, c.Interaction.User.ID) + c.ReplyError() + return + } + c.ReplyModal("secretsanta.invite.set_address_modal."+c.Interaction.GuildID, lang.GetDefault(tp+"msg.invite.modal.set_address.title"), discordgo.ActionsRow{Components: []discordgo.MessageComponent{ + discordgo.TextInput{ + CustomID: "address", + Label: lang.GetDefault(tp + "msg.invite.modal.set_address.label"), + Style: discordgo.TextInputParagraph, + Placeholder: lang.GetDefault(tp + "msg.invite.modal.set_address.placeholder"), + Value: player.Address, + Required: true, + }, + }}) } func (c Component) handleInviteShowAddress(ids []string) {