tried adding notify command
This commit is contained in:
63
command_notify.go
Normal file
63
command_notify.go
Normal file
@@ -0,0 +1,63 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/bwmarrin/discordgo"
|
||||
)
|
||||
|
||||
// disabled
|
||||
var notify_command Command = Command{
|
||||
Definition: discordgo.ApplicationCommand{
|
||||
Name: "notify",
|
||||
Description: "Manage social media notifications.",
|
||||
Options: []*discordgo.ApplicationCommandOption{
|
||||
{
|
||||
Type: discordgo.ApplicationCommandOptionSubCommand,
|
||||
Name: "add",
|
||||
Description: "Set channels where your social media notifications should appear.",
|
||||
Options: []*discordgo.ApplicationCommandOption{
|
||||
{
|
||||
Name: "platform",
|
||||
Type: discordgo.ApplicationCommandOptionString,
|
||||
Description: "The social media platform to receive notifications from.",
|
||||
Required: true,
|
||||
Choices: []*discordgo.ApplicationCommandOptionChoice{
|
||||
{
|
||||
Name: "Twitch",
|
||||
Value: "twitch",
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
Name: "username",
|
||||
Type: discordgo.ApplicationCommandOptionString,
|
||||
Required: true,
|
||||
Description: "The social media platform to receive notifications from.",
|
||||
},
|
||||
{
|
||||
Name: "channel",
|
||||
Type: discordgo.ApplicationCommandOptionChannel,
|
||||
Required: true,
|
||||
Description: "The social media platform to receive notifications from.",
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
Type: discordgo.ApplicationCommandOptionSubCommand,
|
||||
Name: "remove",
|
||||
Description: "Remove a social media notification.",
|
||||
},
|
||||
},
|
||||
},
|
||||
Interact: func(s *discordgo.Session, i *discordgo.InteractionCreate) {
|
||||
options := i.ApplicationCommandData().Options[0]
|
||||
switch options.Name {
|
||||
case "add":
|
||||
switch options.Options[0].Value {
|
||||
case "twitch":
|
||||
fmt.Print("twitch")
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
1
main.go
1
main.go
@@ -29,7 +29,6 @@ func main() {
|
||||
log.Fatal(err)
|
||||
}
|
||||
initTables()
|
||||
|
||||
discord, err := discordgo.New("Bot " + os.Getenv("BOT_TOKEN"))
|
||||
if err != nil {
|
||||
fmt.Println("error creating Discord session,", err)
|
||||
|
@@ -23,7 +23,7 @@ func ready(s *discordgo.Session, event *discordgo.Ready) {
|
||||
_, err := s.ApplicationCommandCreate(s.State.User.ID, guild.ID, &command.Definition)
|
||||
if err != nil {
|
||||
fmt.Println("error creating command,", err)
|
||||
continue // Continue to the next guild
|
||||
continue
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -64,36 +64,3 @@ func removeCommandFromAllGuilds(s *discordgo.Session) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
func hasManageServerPermissions(s *discordgo.Session, userID string, guildID string) bool {
|
||||
member, err := s.GuildMember(guildID, userID)
|
||||
if err != nil {
|
||||
fmt.Printf("Error fetching guild member: %v\n", err)
|
||||
return false
|
||||
}
|
||||
|
||||
guild, err := s.Guild(guildID)
|
||||
if err != nil {
|
||||
fmt.Printf("Error fetching guild: %v\n", err)
|
||||
return false
|
||||
}
|
||||
|
||||
if guild.OwnerID == userID {
|
||||
return true
|
||||
}
|
||||
|
||||
for _, roleID := range member.Roles {
|
||||
role, err := s.State.Role(guildID, roleID)
|
||||
if err != nil {
|
||||
fmt.Printf("Error fetching role: %v\n", err)
|
||||
continue
|
||||
}
|
||||
if role.Permissions&discordgo.PermissionManageServer != 0 || role.Permissions&discordgo.PermissionAdministrator != 0 {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
*/
|
||||
|
Reference in New Issue
Block a user