dndmusicbot/discord.go

40 lines
710 B
Go
Raw Permalink Normal View History

2022-11-18 21:18:12 +00:00
package main
import (
discordspeaker "dndmusicbot/speaker"
"log"
"github.com/bwmarrin/discordgo"
)
func init() {
log.Println("discord.go loading..")
var err error
token := config.GetString("discord.token")
guild := config.GetString("discord.guild")
channel := config.GetString("discord.channel")
app.discord, err = discordgo.New("Bot " + token)
if err != nil {
return
}
// app.discord.LogLevel = discordgo.LogDebug
err = app.discord.Open()
if err != nil {
return
}
app.voice, err = app.discord.ChannelVoiceJoin(guild, channel, false, true)
if err != nil {
return
}
// app.voice.LogLevel = discordgo.LogDebug
discordspeaker.Init(app.voice)
log.Println("discord.go done.")
}