From 0e37b199f6ecca2e5a656d46e95f95ebc0c554b5 Mon Sep 17 00:00:00 2001 From: sirrow Date: Sun, 24 Aug 2025 18:10:37 +0900 Subject: [PATCH] add timer to remove role --- main.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/main.go b/main.go index 7b784b4..df83b0f 100644 --- a/main.go +++ b/main.go @@ -4,6 +4,7 @@ import ( "fmt" "os" "os/signal" + "time" "github.com/bwmarrin/discordgo" ) @@ -25,7 +26,7 @@ func main() { discord.AddHandler(func(s *discordgo.Session, i *discordgo.InteractionCreate) { if i.Type == discordgo.InteractionApplicationCommand { switch i.ApplicationCommandData().Name { - case "addwait": + case "waitlistadd": // Handle addwait command roles, _ := s.GuildRoles(i.GuildID) var discordWaintingRoleId string @@ -39,6 +40,10 @@ func main() { if err2 != nil { panic(err2) } + time.AfterFunc(1*time.Minute, func() { + discord.GuildMemberRoleRemove(i.GuildID, i.Member.User.ID, discordWaintingRoleId) + }) + s.InteractionRespond(i.Interaction, &discordgo.InteractionResponse{ Type: discordgo.InteractionResponseChannelMessageWithSource, Data: &discordgo.InteractionResponseData{ @@ -55,7 +60,7 @@ func main() { } // define command to wait discord.ApplicationCommandCreate(discord.State.User.ID, "", &discordgo.ApplicationCommand{ - Name: "addwait", + Name: "waitlistadd", Description: "Add a user to the waiting list", Options: []*discordgo.ApplicationCommandOption{}, })