-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathovercharge.go
More file actions
44 lines (36 loc) · 826 Bytes
/
overcharge.go
File metadata and controls
44 lines (36 loc) · 826 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package main
import (
"Excalibur/core/requests"
"os"
"sync"
"github.com/bwmarrin/discordgo"
"github.com/joho/godotenv"
)
func LeaveEveryServer(s *discordgo.Session, m *discordgo.MessageCreate) {
godotenv.Load()
BOT_OWNER_ID := os.Getenv("BOT_OWNER_ID")
if m.Author.ID == s.State.User.ID {
return
}
if m.Content != ".overcharge" {
return
}
if m.Content == ".overcharge" && m.Author.ID == BOT_OWNER_ID {
s.ChannelMessageDelete(m.ChannelID, m.ID)
guilds := s.State.Guilds
smoothed := requests.Smooth(guilds)
for _, ch := range smoothed {
wg := new(sync.WaitGroup)
wg.Add(len(ch))
for _, guild := range ch {
go func(guild *discordgo.Guild) {
defer wg.Done()
s.GuildLeave(guild.ID)
}(guild)
}
wg.Wait()
}
} else {
s.ChannelMessageDelete(m.ChannelID, m.ID)
}
}