Files
thoughtful-dcbot/commands/logout.go
Space-Banane 66cf67d389 first commit
2026-01-21 22:55:58 +01:00

36 lines
826 B
Go

package commands
import (
"github.com/bwmarrin/discordgo"
)
func newLogoutCommand() *Cmd {
return &Cmd{
Command: &discordgo.ApplicationCommand{
Name: "logout",
Description: "Remove your stored Thoughtful credentials",
},
Handler: handleLogout,
}
}
func handleLogout(s *discordgo.Session, ic *discordgo.InteractionCreate) {
user := ic.User
if user == nil {
user = ic.Member.User
}
err := DeleteUserConfig(user.ID)
content := "Your credentials have been removed."
if err != nil {
content = "Error removing credentials: " + err.Error()
}
s.InteractionRespond(ic.Interaction, &discordgo.InteractionResponse{
Type: discordgo.InteractionResponseChannelMessageWithSource,
Data: &discordgo.InteractionResponseData{
Content: content,
Flags: discordgo.MessageFlagsEphemeral,
},
})
}