add timer to remove role
This commit is contained in:
9
main.go
9
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{},
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user