Create channels from vocal channel

This commit is contained in:
Matte23
2021-10-29 09:04:27 +02:00
parent 995955ac94
commit 58e540656f
3 changed files with 125 additions and 1 deletions

View File

@@ -1,6 +1,8 @@
package main
import "github.com/bwmarrin/discordgo"
import (
"github.com/bwmarrin/discordgo"
)
func searchChannel(s *discordgo.Session, guildID string, channelName string, channelParent string) (channel *discordgo.Channel) {
channels, _ := s.GuildChannels(guildID)
@@ -16,6 +18,24 @@ func searchChannel(s *discordgo.Session, guildID string, channelName string, cha
return nil
}
func getAllChannelsUnderCategory(s *discordgo.Session, guildID string, channelParent string) (channels []*discordgo.Channel) {
allChannels, _ := s.GuildChannels(guildID)
for _, channel := range allChannels {
if channelParent == "" || channel.ParentID == channelParent {
channels = append(channels, channel)
}
}
return channels
}
func deleteAllChannelsUnderCategory(s *discordgo.Session, guildID string, channelParent string) {
for _, channel := range getAllChannelsUnderCategory(s, guildID, channelParent) {
s.ChannelDelete(channel.ID)
}
}
func searchRole(s *discordgo.Session, guildID string, roleName string) (role *discordgo.Role) {
roles, _ := s.GuildRoles(guildID)
@@ -39,3 +59,17 @@ func searchUser(s *discordgo.Session, guildID string, userName string) (role *di
return nil
}
func contains(s []string, e string) int {
for i, a := range s {
if a == e {
return i
}
}
return -1
}
func remove(s []string, i int) []string {
s[i] = s[len(s)-1]
return s[:len(s)-1]
}