switched to using authentication json file for api keys

This commit is contained in:
2020-06-06 06:04:28 -05:00
parent ede07b71ce
commit ab49ba5d4a
2 changed files with 16 additions and 11 deletions

0
bun Normal file
View File

View File

@@ -1,28 +1,33 @@
package main
import (
"flag"
//"flag"
"fmt"
"os"
"os/signal"
"syscall"
"strings"
"io/ioutil"
"github.com/bwmarrin/discordgo"
"github.com/buger/jsonparser"
)
var (
Token string
)
func init() {
flag.StringVar(&Token, "t", "", "Bot Token")
flag.Parse()
}
func main() {
// read auth file
auth, err := ioutil.ReadFile("auth.json")
if err != nil {
panic(err)
}
// get our discord token
token,err := jsonparser.GetString(auth, "[0]", "token")
if err != nil {
fmt.Println(err)
}
// create Discord session
dg, err := discordgo.New("Bot " + Token)
dg, err := discordgo.New("Bot " + token)
if err != nil {
fmt.Println("Error creating Discord session, ", err)
return