Skip to content

Commit

Permalink
fix: don't test in production
Browse files Browse the repository at this point in the history
Really, don't
  • Loading branch information
TheTipo01 committed Mar 16, 2022
1 parent e830854 commit edb7350
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ func guildCreate(s *discordgo.Session, g *discordgo.GuildCreate) {
lit.Error("Error inserting into the database: %s", err.Error())
}

server[g.ID] = &Server{numberOfMessages: 0, model: &gomarkov.Chain{}}
server[g.ID] = &Server{numberOfMessages: 0, model: gomarkov.NewChain(1)}
}

for _, c := range g.Channels {
Expand Down
4 changes: 2 additions & 2 deletions markov.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func buildModel(guildID string) *gomarkov.Chain {

// saveModel updates the model on the database
func saveModel(guildID string) {
data, _ := server[guildID].model.MarshalJSON()
data, _ := json.Marshal(server[guildID].model)

_, err := db.Exec("UPDATE servers SET model=? WHERE id=?", data, guildID)

Expand All @@ -73,7 +73,7 @@ func loadModel() {
for rows.Next() {
_ = rows.Scan(&data, &guildID)

server[guildID] = &Server{numberOfMessages: 0, model: &gomarkov.Chain{}}
server[guildID] = &Server{numberOfMessages: 0, model: gomarkov.NewChain(1)}

if len(data) == 0 {
server[guildID].model = buildModel(guildID)
Expand Down

0 comments on commit edb7350

Please sign in to comment.