added remove command

This commit is contained in:
2024-02-18 21:14:51 +01:00
parent 3748527a54
commit 8fb88677c3
3 changed files with 49 additions and 17 deletions

View File

@@ -25,14 +25,14 @@ func addTag(guildID, tagName, tagContent string) bool {
return exists
}
func removeTag(guildID, tagName string) {
func removeTag(guildID, tagContent string) {
var exists bool
err := db.QueryRow("SELECT EXISTS (SELECT 1 FROM tags WHERE guild_id = $1 AND tag_name = $2)", guildID, tagName).Scan(&exists)
err := db.QueryRow("SELECT EXISTS (SELECT 1 FROM tags WHERE guild_id = $1 AND tag_content = $2)", guildID, tagContent).Scan(&exists) // that is so dumb next commit i will make the tag IDs
if err != nil {
log.Println(err)
}
if exists {
_, err = db.Exec("DELETE FROM tags WHERE guild_id = $1 AND tag_name = $2", guildID, tagName)
_, err = db.Exec("DELETE FROM tags WHERE guild_id = $1 AND tag_content = $2", guildID, tagContent)
if err != nil {
log.Println(err)
}