diff --git a/discord/discord.go b/discord/discord.go index e75467cc..941150ac 100644 --- a/discord/discord.go +++ b/discord/discord.go @@ -263,7 +263,7 @@ func (b *Bot) messageHandler(s *discordgo.Session, m *discordgo.MessageCreate) { return } - err = b.store.SetData(peerID, address, m.Author.Username, m.Author.ID, amount) + err = b.store.SetData(peerID, address, m.Author.Username, m.Author.ID, referral.DiscordID, amount) if err != nil { log.Printf("error saving faucet information: %v\n", err) } @@ -305,7 +305,7 @@ func (b *Bot) messageHandler(s *discordgo.Session, m *discordgo.MessageCreate) { return } - err = b.store.SetData(peerID, trimmedAddress, m.Author.Username, m.Author.ID, b.cfg.FaucetAmount) + err = b.store.SetData(peerID, trimmedAddress, m.Author.Username, m.Author.ID, "", b.cfg.FaucetAmount) if err != nil { log.Printf("error saving faucet information: %v\n", err) } diff --git a/discord/store.go b/discord/store.go index 7ac9ae77..3f9809f8 100644 --- a/discord/store.go +++ b/discord/store.go @@ -12,10 +12,11 @@ import ( // Validator is a value stored in the cache. type Validator struct { - DiscordName string `json:"discord_name"` - DiscordID string `json:"discord_id"` - ValidatorAddress string `json:"validator_address"` - FaucetAmount float64 `json:"faucet_amount"` + DiscordName string `json:"discord_name"` + DiscordID string `json:"discord_id"` + ValidatorAddress string `json:"validator_address"` + ReferrerDiscordID string `json:"referrer_discord_id"` + FaucetAmount float64 `json:"faucet_amount"` } type ValidatorRoundOne struct { @@ -61,10 +62,11 @@ func LoadData(cfg *config.Config) (*SafeStore, error) { } // SetData Set a given value to the data storage. -func (ss *SafeStore) SetData(peerID, address, discordName, discordID string, amount float64) error { +func (ss *SafeStore) SetData(peerID, address, discordName, discordID, referrerDiscordID string, amount float64) error { ss.syncMap.Store(peerID, &Validator{ DiscordName: discordName, DiscordID: discordID, ValidatorAddress: address, FaucetAmount: amount, + ReferrerDiscordID: referrerDiscordID, }) // save record data, err := marshalJSON(ss.syncMap)