include more bot data
This commit is contained in:
@@ -23,26 +23,42 @@ func BotExists(id string) bool {
|
||||
return true
|
||||
}
|
||||
|
||||
func GetBots() []discord.SimpleUser {
|
||||
type BotData struct {
|
||||
User discord.User `json:"user"`
|
||||
TokenCount int `json:"token_count"`
|
||||
}
|
||||
|
||||
type BotDataSimple struct {
|
||||
User discord.SimpleUser `json:"user"`
|
||||
TokenCount int `json:"token_count"`
|
||||
}
|
||||
|
||||
func GetBots() []BotDataSimple {
|
||||
botIDs, err := client.SMembers(ctx, "bots").Result()
|
||||
if err != nil && err != redis.Nil {
|
||||
panic(err)
|
||||
}
|
||||
bots := make([]discord.SimpleUser, 0)
|
||||
bots := make([]BotDataSimple, 0)
|
||||
for _, id := range botIDs {
|
||||
bots = append(bots, GetBot(id).Simplify())
|
||||
bots = append(bots, BotDataSimple{
|
||||
User: GetBot(id).User.Simplify(),
|
||||
TokenCount: len(TokensUnderBot(id)),
|
||||
})
|
||||
}
|
||||
return bots
|
||||
}
|
||||
|
||||
func GetBot(id string) discord.User {
|
||||
func GetBot(id string) BotData {
|
||||
var bot discord.User
|
||||
key := fmt.Sprintf("bot:%s:data", id)
|
||||
err := client.Get(ctx, key).Scan(&bot)
|
||||
if err != nil && err != redis.Nil {
|
||||
panic(err)
|
||||
}
|
||||
return bot
|
||||
return BotData{
|
||||
User: bot,
|
||||
TokenCount: len(TokensUnderBot(id)),
|
||||
}
|
||||
}
|
||||
|
||||
func ExistsBot(id string) bool {
|
||||
|
||||
Reference in New Issue
Block a user