From 809c6b894d00f4144b87202f0ccc48f84529844f Mon Sep 17 00:00:00 2001 From: sirrow Date: Sun, 24 Aug 2025 17:23:48 +0900 Subject: [PATCH] temp --- go.mod | 8 ++++++++ main.go | 25 +++++++++++++++---------- 2 files changed, 23 insertions(+), 10 deletions(-) diff --git a/go.mod b/go.mod index 6981b94..6563634 100644 --- a/go.mod +++ b/go.mod @@ -1,3 +1,11 @@ module splawaitbot go 1.24.4 + +require github.com/bwmarrin/discordgo v0.29.0 + +require ( + github.com/gorilla/websocket v1.4.2 // indirect + golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b // indirect + golang.org/x/sys v0.0.0-20201119102817-f84b799fce68 // indirect +) diff --git a/main.go b/main.go index 425c32e..7b784b4 100644 --- a/main.go +++ b/main.go @@ -11,7 +11,6 @@ import ( func main() { //discordServerId := os.Getenv("DISCORD_SERVER_ID") //discordChannelId := os.Getenv("DISCORD_CHANNEL_ID") - //discordWaintingRoleId := os.Getenv("DISCORD_WAITING_ROLE_ID") discordToken := os.Getenv("DISCORD_TOKEN") discord, err := discordgo.New("Bot " + discordToken) @@ -21,16 +20,29 @@ func main() { discord.AddHandler(func(s *discordgo.Session, r *discordgo.Ready) { fmt.Println("Bot is now running. Press CTRL+C to exit.") + }) discord.AddHandler(func(s *discordgo.Session, i *discordgo.InteractionCreate) { if i.Type == discordgo.InteractionApplicationCommand { switch i.ApplicationCommandData().Name { case "addwait": // Handle addwait command + roles, _ := s.GuildRoles(i.GuildID) + var discordWaintingRoleId string + for _, role := range roles { + if role.Name == "WAITING" { + discordWaintingRoleId = role.ID + } + } + fmt.Println("GuildId: ", i.GuildID, " User ID: ", i.Member.User.ID, " Role ID: ", discordWaintingRoleId) + err2 := discord.GuildMemberRoleAdd(i.GuildID, i.Member.User.ID, discordWaintingRoleId) + if err2 != nil { + panic(err2) + } s.InteractionRespond(i.Interaction, &discordgo.InteractionResponse{ Type: discordgo.InteractionResponseChannelMessageWithSource, Data: &discordgo.InteractionResponseData{ - Content: "User added to waiting list.", + Content: "User " + i.Member.User.Username + " added to waiting list. ", }, }) } @@ -45,14 +57,7 @@ func main() { discord.ApplicationCommandCreate(discord.State.User.ID, "", &discordgo.ApplicationCommand{ Name: "addwait", Description: "Add a user to the waiting list", - Options: []*discordgo.ApplicationCommandOption{ - { - Type: discordgo.ApplicationCommandOptionUser, - Name: "user", - Description: "The user to add to the waiting list", - Required: true, - }, - }, + Options: []*discordgo.ApplicationCommandOption{}, }) stop := make(chan os.Signal, 1)