session.go 544 B

12345678910111213141516171819202122
  1. package discord
  2. import "git.mgmcomp.net/thisnthat/discordgo"
  3. // GetSession - Get a discord session from the provided token
  4. func GetSession(token string) (*discordgo.Session, error) {
  5. session, err := discordgo.New("Bot " + token)
  6. session.Identify.Intents = discordgo.MakeIntent(discordgo.IntentsAll)
  7. // If we can not create the client then just fatal.
  8. if err != nil {
  9. return nil, err
  10. }
  11. // Open a websocket connection to Discord and begin listening.
  12. err = session.Open()
  13. if err != nil {
  14. return nil, err
  15. }
  16. return session, nil
  17. }