Skip to content

Commit

Permalink
feat: added show address to show match
Browse files Browse the repository at this point in the history
  • Loading branch information
Kesuaheli committed Nov 19, 2024
1 parent c7808cc commit c43264e
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 24 deletions.
4 changes: 0 additions & 4 deletions config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,6 @@ event:
name: 🏠
#id:
#animated: true
secretsanta.invite.show_address:
name: 🏠
#id:
#animated: true

webserver:
favicon: webserver/favicon.png
Expand Down
9 changes: 6 additions & 3 deletions data/lang/de.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -139,12 +139,15 @@ discord.command:
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.button.show_match: Partner anzeigen
msg.invite.show_match.title: Dein Partner ist %s
msg.invite.show_match.description: Bitte breite ein Wichtelgeschenk vor und schicke es ihm/ihr. Halte dich dabei an unsere vereinbarten Regeln.
msg.invite.show_match.address: Adresse
msg.invite.show_match.address_not_set: Dein Partner hat noch keine Adresse eingetragen
msg.invite.set_address: Deine Adresse wurde eingetragen
msg.invite.button.set_address: Deine Adresse eintragen
msg.invite.set_address.changed: Deine Adresse wurde aktualisiert auf
msg.invite.set_address.not_changed: Deine Adresse wurde nicht aktualisiert, weil es die gleiche ist wie vorher.
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
Expand Down
9 changes: 6 additions & 3 deletions data/lang/en.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -139,12 +139,15 @@ discord.command:
msg.invite.title: Invite for secret santa.
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.button.show_match: Show partner
msg.invite.show_match.title: Your partner is %s
msg.invite.show_match.description: Please prepare and send them a secret gift according to our agreed rules.
msg.invite.show_match.address: Address
msg.invite.show_match.address_not_set: Your partner has not set an address yet
msg.invite.set_address: Your address is set
msg.invite.button.set_address: Set your address
msg.invite.set_address.changed: Your address was updated to
msg.invite.set_address.not_changed: Your address was not updated, because it is the same as before.
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
Expand Down
18 changes: 11 additions & 7 deletions modules/secretsanta/handleComponentInvite.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package secretsanta
import (
"cake4everybot/data/lang"
"cake4everybot/util"
"fmt"

"github.com/bwmarrin/discordgo"
)
Expand All @@ -15,9 +16,6 @@ func (c Component) handleInvite(ids []string) {
case "set_address":
c.handleInviteSetAddress(ids)
return
case "show_address":
c.handleInviteShowAddress(ids)
return
default:
log.Printf("Unknown component interaction ID: %s", c.data.CustomID)
}
Expand All @@ -44,6 +42,16 @@ func (c Component) handleInviteShowMatch(ids []string) {
}

e := util.AuthoredEmbed(c.Session, player.Match.Member, tp+"display")
e.Title = fmt.Sprintf(lang.GetDefault(tp+"msg.invite.show_match.title"), player.Match.Member.DisplayName())
e.Description = lang.GetDefault(tp + "msg.invite.show_match.description")
e.Fields = append(e.Fields, &discordgo.MessageEmbedField{
Name: lang.GetDefault(tp + "msg.invite.show_match.address"),
Value: fmt.Sprintf("```\n%s\n```", player.Match.Address),
})
if player.Match.Address == "" {
log.Printf("%s has no address set: %+v", player.Match.Member.DisplayName(), player.Match)
e.Fields[0].Value = lang.GetDefault(tp + "msg.invite.show_match.address_not_set")
}

util.SetEmbedFooter(c.Session, tp+"display", e)
c.ReplyHiddenEmbed(e)
Expand Down Expand Up @@ -86,7 +94,3 @@ func (c Component) handleInviteSetAddress(ids []string) {
},
}})
}

func (c Component) handleInviteShowAddress(ids []string) {

}
6 changes: 0 additions & 6 deletions modules/secretsanta/handleComponentSetup.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,6 @@ func (c Component) handleSetupInvite() {
discordgo.SecondaryButton,
util.GetConfigComponentEmoji("secretsanta.invite.set_address"),
),
util.CreateButtonComponent(
fmt.Sprintf("secretsanta.invite.show_address.%s", c.Interaction.GuildID),
lang.GetDefault(tp+"msg.invite.button.show_address"),
discordgo.SecondaryButton,
util.GetConfigComponentEmoji("secretsanta.invite.show_address"),
),
}},
},
}
Expand Down
2 changes: 1 addition & 1 deletion util/discord.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func AuthoredEmbed[T *discordgo.User | *discordgo.Member](s *discordgo.Session,
panic("Given generic type is not an discord user or member")
}
user = member.User
username = member.Nick
username = member.DisplayName()
}

if username == "" {
Expand Down

0 comments on commit c43264e

Please sign in to comment.