diff --git a/main.go b/main.go index 91da04b..45ba35b 100644 --- a/main.go +++ b/main.go @@ -3,6 +3,7 @@ package main import ( "fmt" "github.com/bwmarrin/discordgo" + "github.com/deckarep/golang-set" "log" "os" "os/signal" @@ -88,7 +89,7 @@ func addCommands() { registerCommand(Command{Trigger: "!mods", Output: "Bei Fragen, Problemen und Beschwerden wende dich bitte an die Moderatoren oder schick mir eine Nachricht beginnend mit !complain, um dich anonym zu beschweren.\nAktuell anwesende Mods werden dir rechts mit dem Rang „Maid“ angezeigt.", Type: CommandTypeFullMatch}) // Features :Pog: - registerCommand(Command{Trigger: "!vc ", Type: CommandTypePrefix, Function: parseVoiceChannelCommand}) + registerCommand(Command{Trigger: "!vc ", Type: CommandTypePrefix, Function: parseVoiceChannelCommand, AllowedChannels: mapset.NewSetWith("525852491976278016")}) // Admin and/or debug registerCommand(Command{Trigger: "<@%s> <3", Output: "<@%s> <3", Type: CommandTypeFullMatch, AdminOnly: true, OutputIsReply: true, RequiresMention: true}) diff --git a/voicechannel.go b/voicechannel.go index b1df72b..8ede646 100644 --- a/voicechannel.go +++ b/voicechannel.go @@ -19,7 +19,7 @@ func parseVoiceChannelCommand(session *discordgo.Session, message *discordgo.Mes return } if userLimit > 99 { - session.ChannelMessageSend(message.ChannelID, fmt.Sprintf("Als ob %d Leute *mit dir* in einen Channel wollen", userLimit-1)) + session.ChannelMessageSend(message.ChannelID, fmt.Sprintf("Als ob %d Leute *mit dir* in einen Channel wollen.", userLimit-1)) log.Printf("%s tried to create a channel with %d slots", userToString(message.Author), userLimit) return } @@ -27,6 +27,7 @@ func parseVoiceChannelCommand(session *discordgo.Session, message *discordgo.Mes Name: fmt.Sprintf("%s’s Volatile Corner", message.Author.Username), Type: discordgo.ChannelTypeGuildVoice, UserLimit: userLimit, + ParentID: "410162599762853909", } channel, err := session.GuildChannelCreateComplex(message.GuildID, createData) if err != nil { @@ -35,16 +36,23 @@ func parseVoiceChannelCommand(session *discordgo.Session, message *discordgo.Mes return } tempChannels = append(tempChannels, channel) - session.GuildMemberMove(config.ServerID, message.Author.ID, channel.ID) + err = session.GuildMemberMove(config.ServerID, message.Author.ID, channel.ID) + if err != nil { + log.Printf("Couldn’t move user %s: %s", userToString(message.Author), err) + } + session.ChannelMessageSend(message.ChannelID, "haaaai~") + log.Printf("Created channel %s", channel.ID) } func checkAndDeleteUnusedChannels(session *discordgo.Session) { for true { - time.Sleep(30 * time.Second) + time.Sleep(15 * time.Second) for i, channel := range tempChannels { if channelIsEmpty(channel.ID) { session.ChannelDelete(channel.ID) tempChannels = remove(tempChannels, i) + log.Printf("Deleted channel %s", channel.ID) + log.Printf("Tempchannels: %d", len(tempChannels)) break } }