Skip to content

Commit

Permalink
fix: ensure we save the data as needed
Browse files Browse the repository at this point in the history
  • Loading branch information
sylvrs committed Nov 26, 2024
1 parent 3bc64e4 commit c639a3b
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions guild.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,10 @@ func (mng *GuildManager) Stop() error {
// err := mng.FetchServiceConfig(&config)
// ...
func (mng *GuildManager) FetchServiceConfig(config interface{}, defaults ...interface{}) error {
mng.connection.AutoMigrate(&config)
return mng.Connection().Where(&ServiceConfiguration{GuildId: mng.guild.ID}).Attrs(defaults).FirstOrCreate(config).Error
mng.connection.AutoMigrate(config)
// Ensure that our guild ID is set in the service configuration
defaults = append(defaults, ServiceConfiguration{GuildId: mng.guild.ID})
return mng.Connection().Where("guild_id = ?", mng.guild.ID).Attrs(defaults...).FirstOrCreate(config).Error
}

// SaveServiceConfig saves the service configuration to the database
Expand Down

0 comments on commit c639a3b

Please sign in to comment.