first commit
This commit is contained in:
35
commands/logout.go
Normal file
35
commands/logout.go
Normal file
@@ -0,0 +1,35 @@
|
||||
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,
|
||||
},
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user