-
Notifications
You must be signed in to change notification settings - Fork 927
/
stateinfo.go
62 lines (51 loc) · 1.99 KB
/
stateinfo.go
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
package stateinfo
import (
"fmt"
"github.com/botlabs-gg/yagpdb/v2/bot"
"github.com/botlabs-gg/yagpdb/v2/commands"
"github.com/botlabs-gg/yagpdb/v2/lib/dcmd"
"github.com/botlabs-gg/yagpdb/v2/lib/discordgo"
"github.com/botlabs-gg/yagpdb/v2/stdcommands/util"
)
var Command = &commands.YAGCommand{
Cooldown: 2,
CmdCategory: commands.CategoryDebug,
Name: "stateinfo",
Description: "Responds with state debug info, Bot Owner only",
HideFromHelp: true,
RunFunc: util.RequireOwner(cmdFuncStateInfo),
}
func cmdFuncStateInfo(data *dcmd.Data) (interface{}, error) {
totalGuilds := 0
totalMembers := 0
guildChannel := 0
totalMessages := 0
// state := bot.State
// totalChannels := len(state.Channels)
// totalGuilds = len(state.Guilds)
// gCop := state.GuildsSlice(false)
shards := bot.ReadyTracker.GetProcessShards()
for _, shard := range shards {
guilds := bot.State.GetShardGuilds(int64(shard))
totalGuilds += len(guilds)
for _, g := range guilds {
guildChannel += len(g.Channels)
}
}
// stats := bot.State.StateStats()
embed := &discordgo.MessageEmbed{
Title: "State size",
Fields: []*discordgo.MessageEmbedField{
{Name: "Guilds", Value: fmt.Sprint(totalGuilds), Inline: true},
{Name: "Members", Value: fmt.Sprintf("%d", totalMembers), Inline: true},
{Name: "Messages", Value: fmt.Sprintf("%d", totalMessages), Inline: true},
{Name: "Guild Channels", Value: fmt.Sprintf("%d", guildChannel), Inline: true},
// {Name: "Total Channels", Value: fmt.Sprintf("%d", totalChannels), Inline: true},
// {Name: "Cache Hits/Misses", Value: fmt.Sprintf("%d - %d", stats.CacheHits, stats.CacheMisses), Inline: true},
// {Name: "Members evicted total", Value: fmt.Sprintf("%d", stats.MembersRemovedTotal), Inline: true},
// {Name: "Cache evicted total", Value: fmt.Sprintf("%d", stats.UserCachceEvictedTotal), Inline: true},
// {Name: "Messages removed total", Value: fmt.Sprintf("%d", stats.MessagesRemovedTotal), Inline: true},
},
}
return embed, nil
}