36 lines
826 B
Go
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,
|
|
},
|
|
})
|
|
}
|