mirror of
https://github.com/diamondburned/arikawa.git
synced 2024-11-30 10:43:30 +00:00
Examples: Added Gateway intents and comments
This commit is contained in:
parent
1dc11549bc
commit
f4635803ee
|
@ -1,3 +1,5 @@
|
||||||
|
// Package main demonstrates an advanced bot that uses the bot router library to
|
||||||
|
// make commands.
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
@ -24,6 +26,10 @@ func main() {
|
||||||
// Subcommand demo, but this can be in another package.
|
// Subcommand demo, but this can be in another package.
|
||||||
ctx.MustRegisterSubcommand(&Debug{})
|
ctx.MustRegisterSubcommand(&Debug{})
|
||||||
|
|
||||||
|
// The bot package will automatically derive out Gateway intents. It
|
||||||
|
// might not catch everything though, so a ctx.Gateway.AddIntents is
|
||||||
|
// always available.
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
// Package main demonstrates a bare simple bot without a state cache. It logs
|
||||||
|
// all messages it sees into stderr.
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
@ -30,6 +32,10 @@ func main() {
|
||||||
}
|
}
|
||||||
defer s.Close()
|
defer s.Close()
|
||||||
|
|
||||||
|
// Add the needed Gateway intents.
|
||||||
|
s.Gateway.AddIntents(gateway.IntentGuildMessages)
|
||||||
|
s.Gateway.AddIntents(gateway.IntentDirectMessages)
|
||||||
|
|
||||||
u, err := s.Me()
|
u, err := s.Me()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalln("Failed to get myself:", err)
|
log.Fatalln("Failed to get myself:", err)
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
// Package main demonstrates the PreHandler API of the State.
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
@ -35,6 +36,10 @@ func main() {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// Add the needed Gateway intents.
|
||||||
|
s.Gateway.AddIntents(gateway.IntentGuildMessages)
|
||||||
|
s.Gateway.AddIntents(gateway.IntentDirectMessages)
|
||||||
|
|
||||||
if err := s.Open(); err != nil {
|
if err := s.Open(); err != nil {
|
||||||
log.Fatalln("Failed to connect:", err)
|
log.Fatalln("Failed to connect:", err)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue