This repository has been archived by the owner on Sep 10, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathmain.go
80 lines (72 loc) · 1.89 KB
/
main.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
package main
import (
"encoding/json"
"os"
"strconv"
"time"
"github.com/xdimgg/starboard/bot"
"github.com/go-pg/pg"
"github.com/go-redis/redis"
)
func getenvInt(key string) int {
if n, err := strconv.Atoi(os.Getenv(key)); err == nil {
return n
}
return 0
}
func main() {
if os.Getenv("MODE") == "prod" {
time.Sleep(time.Second * 10)
}
panic(bot.New(
&bot.Options{
Prefix: os.Getenv("BOT_PREFIX"),
Token: os.Getenv("BOT_TOKEN"),
Locales: os.Getenv("BOT_LOCALES"),
OwnerID: os.Getenv("BOT_OWNER_ID"),
Mode: os.Getenv("MODE"),
SentryDSN: os.Getenv("SENTRY_DSN"),
DiscordLists: []bot.DiscordList{
{
Authorization: os.Getenv("DBL_KEY"),
URL: func(id string) string {
return "https://discordbots.org/api/bots/" + id + "/stats"
},
Serialize: func(shardCount, guildCount int) ([]byte, error) {
return json.Marshal(map[string]int{
"shard_count": shardCount,
"server_count": guildCount,
})
},
},
{
Authorization: os.Getenv("GG_BOTS_KEY"),
URL: func(id string) string {
return "https://discord.bots.gg/api/v1/bots/" + id + "/stats"
},
Serialize: func(shardCount, guildCount int) ([]byte, error) {
return json.Marshal(map[string]int{
"shardCount": shardCount,
"guildCount": guildCount,
})
},
},
},
Guild: os.Getenv("BOT_GUILD"),
GuildLogChannel: os.Getenv("BOT_GUILD_LOG_CHANNEL"),
MemberLogChannel: os.Getenv("BOT_MEMBER_LOG_CHANNEL"),
},
&pg.Options{
Addr: os.Getenv("POSTGRES_ADDR"),
Database: os.Getenv("POSTGRES_DB"),
Password: os.Getenv("POSTGRES_PASSWORD"),
User: os.Getenv("POSTGRES_USER"),
PoolSize: getenvInt("POSTGRES_POOL_SIZE"),
},
&redis.Options{
Addr: os.Getenv("REDIS_ADDR"),
Password: os.Getenv("REDIS_PASSWORD"),
PoolSize: getenvInt("REDIS_POOL_SIZE"),
},
))
}