aboutsummaryrefslogtreecommitdiff
path: root/util.go
blob: 105b5bbd59361644f9478875d407b9193694568f (plain) (blame)
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
package thulani

import (
	"encoding/json"
	"os"

	"github.com/op/go-logging"
)

const help = `wew lad. you should know these commands already.

Usage: ` + "`!thulani [command]`" + `

commands:
**help**:\t\t\t\tprint this help message
**[url]**:\t\t\t   a url with media that thulani can play. queued up to play after everything that's already waiting.
**list, queue**:\tlist items in the queue, as well as the currently-playing item.
**pause**:\t\t\tpause sound.
**resume**:\t\t resume sound.
**die**:\t\t\t\t empty the queue and stop playing.
**skip**:\t\t\t   skip the current item.
`

var log = logging.MustGetLogger("thulani")

type Config struct {
	Trigger      string `json:"trigger"`
	QueueSize    uint   `json:"queue_size"`
	Admin        uint   `json:"admin"`
	OpRole       string `json:"op_role"`
	Server       string `json:"server"`
	VoiceChannel string `json:"voice_channel"`
	Token        string `json:"token"`
}

func handle(err error) {
	if err != nil {
		log.Fatal(err)
	}
}

func LoadConfig(filename string) (*Config, error) {
	file, err := os.Open("config.json")
	if err != nil {
		return nil, err
	}

	var conf Config
	err = json.NewDecoder(file).Decode(&conf)
	return &conf, err
}