Skip to content

Commit

Permalink
feat(Random): added coin flip
Browse files Browse the repository at this point in the history
  • Loading branch information
Kesuaheli committed Dec 27, 2024
1 parent 0022d63 commit 6893fd1
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 0 deletions.
12 changes: 12 additions & 0 deletions config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,18 @@ event:
#animated: true
# Emoji for entering the advent calendar giveaway
adventcalendar: vote.check
random.coin.heads:
name: 👤
#id:
#animated: true
random.coin.tails:
name: 🪙
#id:
#animated: true
random.coin.reflip:
name: 🔄
#id:
#animated: true
secretsanta: vote.yes
secretsanta.invite.show_match:
name: 🎁
Expand Down
2 changes: 2 additions & 0 deletions data/lang/de.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,8 @@ discord.command:
option.coin.description: Wirf eine Münze
option.dice: würfel
option.dice.description: Würfle ein Würfel
option.dice.option.range: bereich
option.dice.option.range.description: "Wie viele Zahlen soll der Würfel haben? (Standard: 6)"
option.teams: gruppen
option.teams.description: Teile Gruppen zu

Expand Down
2 changes: 2 additions & 0 deletions data/lang/en.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,8 @@ discord.command:
option.coin.description: Flip a coin
option.dice: dice
option.dice.description: Roll a dice
option.dice.option.range: range
option.dice.option.range.description: "How many sides does the dice have? (Default: 6)"
option.teams: teams
option.teams.description: Generate teams

Expand Down
11 changes: 11 additions & 0 deletions modules/random/handleSubcommandCoin.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,15 @@ func (cmd subcommandCoin) appCmd() *discordgo.ApplicationCommandOption {
}

func (cmd subcommandCoin) handle() {
side := "heads"
if rand.IntN(2) == 1 {
side = "tails"
}
reflipButton := util.CreateButtonComponent(
"coin.reflip",
lang.GetDefault(tp+"option.coin.reflip"),
discordgo.PrimaryButton,
util.GetConfigComponentEmoji("random.coin.reflip"))
components := []discordgo.MessageComponent{reflipButton}
cmd.ReplyComponents(components, util.GetConfigEmoji("random.coin."+side).MessageFormat())
}

0 comments on commit 6893fd1

Please sign in to comment.