Skip to content

Commit

Permalink
added address modal
Browse files Browse the repository at this point in the history
  • Loading branch information
Kesuaheli committed Nov 17, 2024
1 parent 6710858 commit a381177
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 1 deletion.
7 changes: 7 additions & 0 deletions data/lang/de.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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**.
Expand Down
9 changes: 8 additions & 1 deletion data/lang/en.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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**.
Expand Down
35 changes: 35 additions & 0 deletions modules/secretsanta/handleComponentInvite.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package secretsanta

import (
"cake4everybot/data/lang"
"cake4everybot/util"

"github.com/bwmarrin/discordgo"
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit a381177

Please sign in to comment.