master
Marc 2021-05-28 16:51:34 +01:00
parent 154bafa507
commit 937a6639cc
No known key found for this signature in database
GPG Key ID: 0657563F705ACAAE
1 changed files with 49 additions and 7 deletions

View File

@ -18,7 +18,11 @@ func (f *Features) handleSetSlowmode(s *discordgo.Session, m *discordgo.MessageC
return errors.New("You must supply at least an amount of time") return errors.New("You must supply at least an amount of time")
} }
// slowmodeTime = slowmodeSplit[1] slowmodeTimeStr := slowmodeSplit[1]
slowModeTime, err := strconv.Atoi(slowmodeTimeStr)
if err != nil {
return err
}
if len(slowmodeSplit) == 3 { if len(slowmodeSplit) == 3 {
if slowmodeSplit[2] == "all" { if slowmodeSplit[2] == "all" {
@ -29,20 +33,20 @@ func (f *Features) handleSetSlowmode(s *discordgo.Session, m *discordgo.MessageC
for _, channel := range channels { for _, channel := range channels {
s.ChannelEditComplex(channel.ID, &discordgo.ChannelEdit{ s.ChannelEditComplex(channel.ID, &discordgo.ChannelEdit{
RateLimitPerUser: 10, RateLimitPerUser: slowModeTime,
}) })
} }
} }
} } else {
_, err := s.ChannelEditComplex(m.ChannelID, &discordgo.ChannelEdit{ _, err := s.ChannelEditComplex(m.ChannelID, &discordgo.ChannelEdit{
RateLimitPerUser: 10, RateLimitPerUser: slowModeTime,
}) })
if err != nil { if err != nil {
return err return err
} }
}
msg := f.CreateDefinedEmbed("Slow Mode", "Setting Slow Mode", "success", m.Author) msg := f.CreateDefinedEmbed("Slow Mode", "Successfully set Slow Mode to `"+slowmodeTimeStr+"`.", "success", m.Author)
_, err = s.ChannelMessageSendEmbed(m.ChannelID, msg) _, err = s.ChannelMessageSendEmbed(m.ChannelID, msg)
if err != nil { if err != nil {
return err return err
@ -51,6 +55,44 @@ func (f *Features) handleSetSlowmode(s *discordgo.Session, m *discordgo.MessageC
return nil return nil
} }
func (f *Features) handleUnsetSlowmode(s *discordgo.Session, m *discordgo.MessageCreate) error {
if !f.Permissions.CheckAdminRole(m.Member) {
return errors.New("You do not have permissions to use that command.")
}
slowmodeSplit := strings.Split(m.Content, " ")
if len(slowmodeSplit) == 2 {
if slowmodeSplit[1] == "all" {
channels, err := s.GuildChannels(f.Config.GuildID)
if err != nil {
return err
}
for _, channel := range channels {
s.ChannelEditComplex(channel.ID, &discordgo.ChannelEdit{
RateLimitPerUser: 0,
})
}
}
} else {
_, err := s.ChannelEditComplex(m.ChannelID, &discordgo.ChannelEdit{
RateLimitPerUser: 0,
})
if err != nil {
return err
}
}
msg := f.CreateDefinedEmbed("Slow Mode", "Successfully unset Slow Mode", "success", m.Author)
_, err := s.ChannelMessageSendEmbed(m.ChannelID, msg)
if err != nil {
return err
}
return nil
}
func (f *Features) handlePurgeChannel(s *discordgo.Session, m *discordgo.MessageCreate) error { func (f *Features) handlePurgeChannel(s *discordgo.Session, m *discordgo.MessageCreate) error {
if !f.Permissions.CheckAdminRole(m.Member) { if !f.Permissions.CheckAdminRole(m.Member) {
return errors.New("You do not have permissions to use that command.") return errors.New("You do not have permissions to use that command.")