temp
This commit is contained in:
8
go.mod
8
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
|
||||
)
|
||||
|
||||
25
main.go
25
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)
|
||||
|
||||
Reference in New Issue
Block a user