add timer to remove role
This commit is contained in:
9
main.go
9
main.go
@@ -4,6 +4,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"os/signal"
|
"os/signal"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/bwmarrin/discordgo"
|
"github.com/bwmarrin/discordgo"
|
||||||
)
|
)
|
||||||
@@ -25,7 +26,7 @@ func main() {
|
|||||||
discord.AddHandler(func(s *discordgo.Session, i *discordgo.InteractionCreate) {
|
discord.AddHandler(func(s *discordgo.Session, i *discordgo.InteractionCreate) {
|
||||||
if i.Type == discordgo.InteractionApplicationCommand {
|
if i.Type == discordgo.InteractionApplicationCommand {
|
||||||
switch i.ApplicationCommandData().Name {
|
switch i.ApplicationCommandData().Name {
|
||||||
case "addwait":
|
case "waitlistadd":
|
||||||
// Handle addwait command
|
// Handle addwait command
|
||||||
roles, _ := s.GuildRoles(i.GuildID)
|
roles, _ := s.GuildRoles(i.GuildID)
|
||||||
var discordWaintingRoleId string
|
var discordWaintingRoleId string
|
||||||
@@ -39,6 +40,10 @@ func main() {
|
|||||||
if err2 != nil {
|
if err2 != nil {
|
||||||
panic(err2)
|
panic(err2)
|
||||||
}
|
}
|
||||||
|
time.AfterFunc(1*time.Minute, func() {
|
||||||
|
discord.GuildMemberRoleRemove(i.GuildID, i.Member.User.ID, discordWaintingRoleId)
|
||||||
|
})
|
||||||
|
|
||||||
s.InteractionRespond(i.Interaction, &discordgo.InteractionResponse{
|
s.InteractionRespond(i.Interaction, &discordgo.InteractionResponse{
|
||||||
Type: discordgo.InteractionResponseChannelMessageWithSource,
|
Type: discordgo.InteractionResponseChannelMessageWithSource,
|
||||||
Data: &discordgo.InteractionResponseData{
|
Data: &discordgo.InteractionResponseData{
|
||||||
@@ -55,7 +60,7 @@ func main() {
|
|||||||
}
|
}
|
||||||
// define command to wait
|
// define command to wait
|
||||||
discord.ApplicationCommandCreate(discord.State.User.ID, "", &discordgo.ApplicationCommand{
|
discord.ApplicationCommandCreate(discord.State.User.ID, "", &discordgo.ApplicationCommand{
|
||||||
Name: "addwait",
|
Name: "waitlistadd",
|
||||||
Description: "Add a user to the waiting list",
|
Description: "Add a user to the waiting list",
|
||||||
Options: []*discordgo.ApplicationCommandOption{},
|
Options: []*discordgo.ApplicationCommandOption{},
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user