Fixed example to actually stay connected :) Thanks Rivalo
This commit is contained in:
parent
5c2e3c6866
commit
c50848e6a9
1 changed files with 8 additions and 1 deletions
|
@ -30,6 +30,7 @@ func main() {
|
|||
// event that happens for every new message on any channel
|
||||
Session := discordgo.Session{
|
||||
OnMessageCreate: messageCreate,
|
||||
OnReady: ready,
|
||||
}
|
||||
|
||||
// Login to the Discord server and store the authentication token
|
||||
|
@ -57,6 +58,12 @@ func main() {
|
|||
return
|
||||
}
|
||||
|
||||
func ready(s *discordgo.Session, r discordgo.Ready) {
|
||||
// start the Heartbeat. This is required
|
||||
// to keep the websocket connection open
|
||||
go s.Heartbeat(r.HeartbeatInterval)
|
||||
}
|
||||
|
||||
func messageCreate(s *discordgo.Session, m discordgo.Message) {
|
||||
fmt.Printf("%25d %s %20s > %s\n", m.ChannelID, time.Now().Format(time.Stamp), m.Author.Username, m.Content)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue