|
@@ -0,0 +1,21 @@
|
|
|
+package discord
|
|
|
+
|
|
|
+import "github.com/bwmarrin/discordgo"
|
|
|
+
|
|
|
+// GetSession - Get a discord session from the provided token
|
|
|
+func GetSession(token string) (*discordgo.Session, error) {
|
|
|
+ session, err := discordgo.New("Bot " + token)
|
|
|
+
|
|
|
+ // If we can not create the client then just fatal.
|
|
|
+ if err != nil {
|
|
|
+ return nil, err
|
|
|
+ }
|
|
|
+
|
|
|
+ // Open a websocket connection to Discord and begin listening.
|
|
|
+ err = session.Open()
|
|
|
+ if err != nil {
|
|
|
+ return nil, err
|
|
|
+ }
|
|
|
+
|
|
|
+ return session, nil
|
|
|
+}
|