Browse Source

Minor changes to the temporary voice channels

master
kageru 3 years ago
parent
commit
a99496377e
Signed by: kageru
GPG Key ID: 8282A2BEA4ADA3D2
  1. 3
      main.go
  2. 14
      voicechannel.go

3
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})

14
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
}
}

Loading…
Cancel
Save