This commit is contained in:
2024-11-04 11:14:43 -06:00
parent b805f27d0e
commit 359520fe83
4 changed files with 13 additions and 28 deletions

View File

@ -25,11 +25,6 @@ func HandleCommand(commandName string, cooldownDuration time.Duration, handler C
log.Printf("Error storing user: %v", dbErr)
}
// Rest of your existing HandleCommand logic...
if !CheckAndApplyCooldown(s, i, commandName, cooldownDuration) {
return
}
if !CheckAndApplyCooldown(s, i, commandName, cooldownDuration) {
return
}

View File

@ -10,7 +10,7 @@ import (
"sort"
"strings"
"github.com/tursodatabase/go-libsql"
_ "github.com/tursodatabase/libsql-client-go/libsql"
)
var DBClient *sql.DB
@ -23,17 +23,15 @@ func InitDB() error {
return fmt.Errorf("database configuration missing")
}
connector, err := libsql.NewEmbeddedReplicaConnector(
"./himbot.db",
dbUrl,
libsql.WithAuthToken(dbToken),
)
finalDBUrl := fmt.Sprintf("%s?authToken=%s", dbUrl, dbToken)
if err != nil {
return fmt.Errorf("failed to create client: %w", err)
client, clientError := sql.Open("libsql", finalDBUrl)
if clientError != nil {
fmt.Fprintf(os.Stderr, "failed to open db %s: %s", dbUrl, clientError)
os.Exit(1)
}
client := sql.OpenDB(connector)
DBClient = client
return runMigrations()