PiZzA
All checks were successful
Docker Deploy / build-and-push (push) Successful in 3m23s

This commit is contained in:
2026-01-27 13:52:57 -07:00
parent 9694a42f3f
commit 221c5cec97
9 changed files with 348 additions and 5 deletions

View File

@@ -87,3 +87,61 @@ func BalanceSendCommand(s *discordgo.Session, i *discordgo.InteractionCreate) (s
return fmt.Sprintf("💸 Successfully sent %d Himbucks to %s! 💸", amount, recipient.Username), nil
}
func GiveCommand(s *discordgo.Session, i *discordgo.InteractionCreate) (string, error) {
if !isAdmin(i.Member.User.ID) {
s.InteractionResponseDelete(i.Interaction)
s.FollowupMessageCreate(i.Interaction, true, &discordgo.WebhookParams{
Content: "You do not have permission to use this command.",
Flags: discordgo.MessageFlagsEphemeral,
})
return "", nil
}
options := i.ApplicationCommandData().Options
var recipientID string
var amount int
for _, opt := range options {
switch opt.Name {
case "user":
recipientID = opt.UserValue(nil).ID
case "amount":
amount = int(opt.IntValue())
}
}
recipient, err := s.User(recipientID)
if err != nil {
return "", fmt.Errorf("failed to get recipient info: %w", err)
}
_, err = lib.GetOrCreateUserWithGuild(recipientID, recipient.Username, i.GuildID)
if err != nil {
return "", fmt.Errorf("failed to initialize recipient profile: %w", err)
}
err = lib.GiveHimbucks(recipientID, i.GuildID, amount)
if err != nil {
return "", fmt.Errorf("failed to give himbucks: %w", err)
}
action := "given to"
if amount < 0 {
action = "taken from"
amount = -amount
}
return fmt.Sprintf("✅ Successfully %s %s %d Himbucks.", action, recipient.Username, amount), nil
}
func isAdmin(userID string) bool {
for _, adminID := range lib.AppConfig.AdminIDs {
if userID == adminID {
return true
}
}
return false
}