globals.go (view raw)
1package main
2
3import (
4 "fmt"
5 "os"
6
7 "github.com/BiRabittoh/disgord/myconfig"
8 "github.com/BiRabittoh/disgord/mylog"
9 "github.com/bwmarrin/discordgo"
10 "github.com/kkdai/youtube/v2"
11)
12
13const (
14 helpFmt = "%s - _%s_"
15)
16
17type KeyValue struct {
18 Key string `json:"key"`
19 Value string `json:"value"`
20}
21
22type Config struct {
23 ApplicationID string `json:"applicationId"`
24 Token string `json:"token"`
25
26 Prefix string `json:"prefix"`
27
28 Outros []KeyValue `json:"outros"`
29 Radios []KeyValue `json:"radios"`
30
31 MagazineSize uint `json:"magazineSize"`
32}
33
34type BotCommand struct {
35 Handler func([]string, *discordgo.Session, *discordgo.MessageCreate) string
36 ShortCode string
37 Help string
38}
39
40func formatCommand(command string) string {
41 return fmt.Sprintf("`%s%s`", config.Values.Prefix, command)
42}
43
44func (bc BotCommand) FormatHelp(command string) string {
45 var shortCodeStr string
46 if bc.ShortCode != "" {
47 shortCodeStr = fmt.Sprintf(" (%s)", formatCommand(bc.ShortCode))
48 }
49 return fmt.Sprintf(helpFmt, formatCommand(command)+shortCodeStr, bc.Help)
50}
51
52var (
53 discordToken string
54 appID string
55 config *myconfig.Config[Config]
56
57 logger = mylog.NewLogger(os.Stdout, "main", mylog.DEBUG)
58 yt = youtube.Client{}
59)