From 3cf4816e18601b1d7027c82d7ddcdb0dde1a8206 Mon Sep 17 00:00:00 2001 From: Chris Rhodes Date: Tue, 4 Oct 2016 19:51:08 -0700 Subject: [PATCH 01/13] Remove 1.5 from travis as golint seems to have lost support. --- .travis.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 45b0582..9eb2c71 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,5 @@ language: go go: - - 1.5 - 1.6 - tip install: From f31b65315b6156aa262ccd71d3907facf7241b2b Mon Sep 17 00:00:00 2001 From: Chris Rhodes Date: Tue, 4 Oct 2016 20:01:07 -0700 Subject: [PATCH 02/13] Bring back 1.5, make lint non fatal. --- .travis.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 9eb2c71..b511e94 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,6 @@ language: go go: + - 1.5 - 1.6 - tip install: @@ -9,5 +10,5 @@ install: script: - diff <(gofmt -d .) <(echo -n) - go vet -x ./... - - golint -set_exit_status ./... + - golint ./... - go test -v -race ./... From 7b7b45cfba2c2e53057bc46ab9d6a837fd1d3602 Mon Sep 17 00:00:00 2001 From: Chris Rhodes Date: Tue, 4 Oct 2016 20:01:50 -0700 Subject: [PATCH 03/13] Fix lint warnings. --- restapi.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/restapi.go b/restapi.go index 337a7f8..f4ffaf1 100644 --- a/restapi.go +++ b/restapi.go @@ -376,9 +376,9 @@ func (s *Session) UserGuildSettingsEdit(guildID string, settings *UserGuildSetti return } +// UserChannelPermissions returns the permission of a user in a channel. // NOTE: This function is now deprecated and will be removed in the future. // Please see the same function inside state.go -// UserChannelPermissions returns the permission of a user in a channel. // userID : The ID of the user to calculate permissions for. // channelID : The ID of the channel to calculate permission for. func (s *Session) UserChannelPermissions(userID, channelID string) (apermissions int, err error) { From 4b9d2e31ccf04b3ade007603d216ac7e46e423f2 Mon Sep 17 00:00:00 2001 From: Chris Rhodes Date: Tue, 4 Oct 2016 20:07:32 -0700 Subject: [PATCH 04/13] Remove 1.5, lint is broken :( :killme: --- .travis.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index b511e94..0febcbf 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,5 @@ language: go go: - - 1.5 - 1.6 - tip install: From c5abbfa42ecd88bf8718d50329e41a6a04a364a7 Mon Sep 17 00:00:00 2001 From: Austin Davis Date: Tue, 4 Oct 2016 15:45:36 -0600 Subject: [PATCH 05/13] Updates docs to include the newly required "Bot" infront of bot user tokens. (#266) --- examples/airhorn/README.md | 2 +- examples/avatar/localfile/README.md | 4 ++-- examples/avatar/url/README.md | 4 ++-- examples/mytoken/README.md | 10 ++++++++-- examples/new_basic/README.md | 12 +++++++++--- examples/pingpong/README.md | 10 ++++++++-- 6 files changed, 30 insertions(+), 12 deletions(-) diff --git a/examples/airhorn/README.md b/examples/airhorn/README.md index 562e2c9..44f4d52 100644 --- a/examples/airhorn/README.md +++ b/examples/airhorn/README.md @@ -27,7 +27,7 @@ Usage of ./airhorn: The below example shows how to start the bot. ```sh -./airhorn -t +./airhorn -t "Bot YOUR_BOT_TOKEN" ``` ### Creating sounds diff --git a/examples/avatar/localfile/README.md b/examples/avatar/localfile/README.md index 9a39e0a..cf15472 100644 --- a/examples/avatar/localfile/README.md +++ b/examples/avatar/localfile/README.md @@ -37,5 +37,5 @@ Usage of ./ocalfile: For example to start application with Token and a non-default avatar: ```sh -./localfile -t "YOUR_BOT_TOKEN" -f "./pathtoavatar.jpg" -``` \ No newline at end of file +./localfile -t "Bot YOUR_BOT_TOKEN" -f "./pathtoavatar.jpg" +``` diff --git a/examples/avatar/url/README.md b/examples/avatar/url/README.md index 6247f00..340fd68 100644 --- a/examples/avatar/url/README.md +++ b/examples/avatar/url/README.md @@ -37,5 +37,5 @@ Usage of ./url: For example to start application with Token and a non-default avatar: ```sh -./url -t "YOUR_BOT_TOKEN" -l "http://bwmarrin.github.io/discordgo/img/discordgo.png" -``` \ No newline at end of file +./url -t "Bot YOUR_BOT_TOKEN" -l "http://bwmarrin.github.io/discordgo/img/discordgo.png" +``` diff --git a/examples/mytoken/README.md b/examples/mytoken/README.md index 4450873..a870615 100644 --- a/examples/mytoken/README.md +++ b/examples/mytoken/README.md @@ -2,12 +2,12 @@ MyToken Example ==== -This example demonstrates how to utilize DiscordGo to print out the +This example demonstrates how to utilize DiscordGo to print out the Authentication Token for a given user account. ### Build -This assumes you already have a working Go environment setup and that +This assumes you already have a working Go environment setup and that DiscordGo is correctly installed on your system. ```sh @@ -33,3 +33,9 @@ authentication. ```sh ./mytoken -e EmailHere -p PasswordHere ``` + +The below example shows how to start the bot using the bot user's token + +```sh +./pingpong -t "Bot YOUR_BOT_TOKEN" +``` diff --git a/examples/new_basic/README.md b/examples/new_basic/README.md index d45523e..c5557ff 100644 --- a/examples/new_basic/README.md +++ b/examples/new_basic/README.md @@ -2,14 +2,14 @@ Basic New Example ==== -This example demonstrates how to utilize DiscordGo to connect to Discord +This example demonstrates how to utilize DiscordGo to connect to Discord and print out all received chat messages. This example uses the high level New() helper function to connect to Discord. ### Build -This assumes you already have a working Go environment setup and that +This assumes you already have a working Go environment setup and that DiscordGo is correctly installed on your system. ```sh @@ -18,7 +18,7 @@ go build ### Usage -You must authenticate using either an Authentication Token or both Email and +You must authenticate using either an Authentication Token or both Email and Password for an account. Keep in mind official Bot accounts only support authenticating via Token. @@ -39,3 +39,9 @@ authentication. ```sh ./new_basic -e EmailHere -p PasswordHere ``` + +The below example shows how to start the bot using the bot user's token + +```sh +./new_basic -t "Bot YOUR_BOT_TOKEN" +``` diff --git a/examples/pingpong/README.md b/examples/pingpong/README.md index 267d4ad..0eb43eb 100644 --- a/examples/pingpong/README.md +++ b/examples/pingpong/README.md @@ -8,7 +8,7 @@ This Bot will respond to "ping" with "Pong!" and "pong" with "Ping!". ### Build -This assumes you already have a working Go environment setup and that +This assumes you already have a working Go environment setup and that DiscordGo is correctly installed on your system. ```sh @@ -17,7 +17,7 @@ go build ### Usage -You must authenticate using either an Authentication Token or both Email and +You must authenticate using either an Authentication Token or both Email and Password for an account. Keep in mind official Bot accounts only support authenticating via Token. @@ -38,3 +38,9 @@ authentication. ```sh ./pingpong -e EmailHere -p PasswordHere ``` + +The below example shows how to start the bot using the bot user's token + +```sh +./pingpong -t "BOT YOUR_BOT_TOKEN" +``` From f878362d73b01a051091faaa012deeb7a85204af Mon Sep 17 00:00:00 2001 From: Austin Davis Date: Thu, 13 Oct 2016 20:14:03 -0600 Subject: [PATCH 06/13] casing matters for some reason tried BOT and it returns a 401. (#268) Also got the name of the executable wrong in mytoken (damn copy paste...) --- examples/mytoken/README.md | 2 +- examples/pingpong/README.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/mytoken/README.md b/examples/mytoken/README.md index a870615..fa77bab 100644 --- a/examples/mytoken/README.md +++ b/examples/mytoken/README.md @@ -37,5 +37,5 @@ authentication. The below example shows how to start the bot using the bot user's token ```sh -./pingpong -t "Bot YOUR_BOT_TOKEN" +./mytoken -t "Bot YOUR_BOT_TOKEN" ``` diff --git a/examples/pingpong/README.md b/examples/pingpong/README.md index 0eb43eb..454594b 100644 --- a/examples/pingpong/README.md +++ b/examples/pingpong/README.md @@ -42,5 +42,5 @@ authentication. The below example shows how to start the bot using the bot user's token ```sh -./pingpong -t "BOT YOUR_BOT_TOKEN" +./pingpong -t "Bot YOUR_BOT_TOKEN" ``` From 4c32e412881afdeded92870b73f5727c2433b09e Mon Sep 17 00:00:00 2001 From: Chris Rhodes Date: Sat, 29 Oct 2016 16:30:07 -0700 Subject: [PATCH 07/13] Update examples to use Bot tokens. --- examples/airhorn/README.md | 4 ++-- examples/airhorn/main.go | 6 +++--- examples/avatar/localfile/README.md | 2 +- examples/avatar/url/README.md | 2 +- examples/new_basic/README.md | 24 ++++++------------------ examples/new_basic/main.go | 13 ++++--------- examples/pingpong/README.md | 22 +++++----------------- examples/pingpong/main.go | 14 +++++--------- 8 files changed, 27 insertions(+), 60 deletions(-) diff --git a/examples/airhorn/README.md b/examples/airhorn/README.md index 44f4d52..984fd6b 100644 --- a/examples/airhorn/README.md +++ b/examples/airhorn/README.md @@ -21,13 +21,13 @@ cp ../src/github.com/bwmarrin/discordgo/examples/airhorn/airhorn.dca . ``` Usage of ./airhorn: -t string - Account Token + Bot Token ``` The below example shows how to start the bot. ```sh -./airhorn -t "Bot YOUR_BOT_TOKEN" +./airhorn -t YOUR_BOT_TOKEN ``` ### Creating sounds diff --git a/examples/airhorn/main.go b/examples/airhorn/main.go index cc61301..3afe047 100644 --- a/examples/airhorn/main.go +++ b/examples/airhorn/main.go @@ -13,7 +13,7 @@ import ( ) func init() { - flag.StringVar(&token, "t", "", "Account Token") + flag.StringVar(&token, "t", "", "Bot Token") flag.Parse() } @@ -34,8 +34,8 @@ func main() { return } - // Create a new Discord session using the provided token. - dg, err := discordgo.New(token) + // Create a new Discord session using the provided bot token. + dg, err := discordgo.New("Bot " + token) if err != nil { fmt.Println("Error creating Discord session: ", err) return diff --git a/examples/avatar/localfile/README.md b/examples/avatar/localfile/README.md index cf15472..1e2bf29 100644 --- a/examples/avatar/localfile/README.md +++ b/examples/avatar/localfile/README.md @@ -34,7 +34,7 @@ Usage of ./ocalfile: Avatar File Name. ``` -For example to start application with Token and a non-default avatar: +For example to start application with a bot token and a non-default avatar: ```sh ./localfile -t "Bot YOUR_BOT_TOKEN" -f "./pathtoavatar.jpg" diff --git a/examples/avatar/url/README.md b/examples/avatar/url/README.md index 340fd68..e11e0a8 100644 --- a/examples/avatar/url/README.md +++ b/examples/avatar/url/README.md @@ -34,7 +34,7 @@ Usage of ./url: Link to the avatar image. ``` -For example to start application with Token and a non-default avatar: +For example to start application with a bot token and a non-default avatar: ```sh ./url -t "Bot YOUR_BOT_TOKEN" -l "http://bwmarrin.github.io/discordgo/img/discordgo.png" diff --git a/examples/new_basic/README.md b/examples/new_basic/README.md index c5557ff..b51a494 100644 --- a/examples/new_basic/README.md +++ b/examples/new_basic/README.md @@ -3,7 +3,7 @@ Basic New Example ==== This example demonstrates how to utilize DiscordGo to connect to Discord -and print out all received chat messages. +and print out all received chat messages. This example uses the high level New() helper function to connect to Discord. @@ -18,30 +18,18 @@ go build ### Usage -You must authenticate using either an Authentication Token or both Email and -Password for an account. Keep in mind official Bot accounts only support -authenticating via Token. +This example uses bot tokens for authentication only. +While user/password is supported by DiscordGo, it is not recommended. ``` ./new_basic --help Usage of ./new_basic: - -e string - Account Email - -p string - Account Password -t string - Account Token + Bot Token ``` -The below example shows how to start the bot using an Email and Password for -authentication. +The below example shows how to start the bot ```sh -./new_basic -e EmailHere -p PasswordHere -``` - -The below example shows how to start the bot using the bot user's token - -```sh -./new_basic -t "Bot YOUR_BOT_TOKEN" +./new_basic -t YOUR_BOT_TOKEN ``` diff --git a/examples/new_basic/main.go b/examples/new_basic/main.go index c3861ac..0191bb0 100644 --- a/examples/new_basic/main.go +++ b/examples/new_basic/main.go @@ -10,24 +10,19 @@ import ( // Variables used for command line parameters var ( - Email string - Password string - Token string + Token string ) func init() { - flag.StringVar(&Email, "e", "", "Account Email") - flag.StringVar(&Password, "p", "", "Account Password") - flag.StringVar(&Token, "t", "", "Account Token") + flag.StringVar(&Token, "t", "", "Bot Token") flag.Parse() } func main() { - // Create a new Discord session using the provided login information. - // Use discordgo.New(Token) to just use a token for login. - dg, err := discordgo.New(Email, Password, Token) + // Create a new Discord session using the provided bot token. + dg, err := discordgo.New("Bot " + Token) if err != nil { fmt.Println("error creating Discord session,", err) return diff --git a/examples/pingpong/README.md b/examples/pingpong/README.md index 454594b..d2ad61f 100644 --- a/examples/pingpong/README.md +++ b/examples/pingpong/README.md @@ -17,30 +17,18 @@ go build ### Usage -You must authenticate using either an Authentication Token or both Email and -Password for an account. Keep in mind official Bot accounts only support -authenticating via Token. +This example uses bot tokens for authentication only. +While user/password is supported by DiscordGo, it is not recommended. ``` ./pingpong --help Usage of ./pingpong: - -e string - Account Email - -p string - Account Password -t string - Account Token + Bot Token ``` -The below example shows how to start the bot using an Email and Password for -authentication. +The below example shows how to start the bot ```sh -./pingpong -e EmailHere -p PasswordHere -``` - -The below example shows how to start the bot using the bot user's token - -```sh -./pingpong -t "Bot YOUR_BOT_TOKEN" +./pingpong -t YOUR_BOT_TOKEN ``` diff --git a/examples/pingpong/main.go b/examples/pingpong/main.go index e6893ca..2edd957 100644 --- a/examples/pingpong/main.go +++ b/examples/pingpong/main.go @@ -9,24 +9,20 @@ import ( // Variables used for command line parameters var ( - Email string - Password string - Token string - BotID string + Token string + BotID string ) func init() { - flag.StringVar(&Email, "e", "", "Account Email") - flag.StringVar(&Password, "p", "", "Account Password") - flag.StringVar(&Token, "t", "", "Account Token") + flag.StringVar(&Token, "t", "", "Bot Token") flag.Parse() } func main() { - // Create a new Discord session using the provided login information. - dg, err := discordgo.New(Email, Password, Token) + // Create a new Discord session using the provided bot token. + dg, err := discordgo.New("Bot " + Token) if err != nil { fmt.Println("error creating Discord session,", err) return From 4edcbf8e531587f17036e722180c9cdcf5309d82 Mon Sep 17 00:00:00 2001 From: Chris Rhodes Date: Sat, 5 Nov 2016 00:15:16 -0700 Subject: [PATCH 08/13] Reduce severity of wsConn close error logging. --- wsapi.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/wsapi.go b/wsapi.go index a19c384..2ed8208 100644 --- a/wsapi.go +++ b/wsapi.go @@ -655,7 +655,7 @@ func (s *Session) Close() (err error) { // frame and wait for the server to close the connection. err := s.wsConn.WriteMessage(websocket.CloseMessage, websocket.FormatCloseMessage(websocket.CloseNormalClosure, "")) if err != nil { - s.log(LogError, "error closing websocket, %s", err) + s.log(LogInformational, "error closing websocket, %s", err) } // TODO: Wait for Discord to actually close the connection. @@ -664,7 +664,7 @@ func (s *Session) Close() (err error) { s.log(LogInformational, "closing gateway websocket") err = s.wsConn.Close() if err != nil { - s.log(LogError, "error closing websocket, %s", err) + s.log(LogInformational, "error closing websocket, %s", err) } s.wsConn = nil From ddfeefaf75c317e057bc870a2aaa8c98d9d51431 Mon Sep 17 00:00:00 2001 From: Chris Rhodes Date: Wed, 23 Nov 2016 17:18:05 -0800 Subject: [PATCH 09/13] Update discord.go --- discord.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/discord.go b/discord.go index d1cfddf..cc0ebd5 100644 --- a/discord.go +++ b/discord.go @@ -27,6 +27,8 @@ const VERSION = "0.13.0" // There are 3 ways to call New: // With a single auth token - All requests will use the token blindly, // no verification of the token will be done and requests may fail. +// IF THE TOKEN IS FOR A BOT, IT MUST BE PREFIXED WITH `BOT ` +// eg: `"Bot "` // With an email and password - Discord will sign in with the provided // credentials. // With an email, password and auth token - Discord will verify the auth From b5698e658d8bf72f46d5b334d8ea39642f3b1049 Mon Sep 17 00:00:00 2001 From: Matthew Gerstman Date: Sun, 27 Nov 2016 23:48:33 -0500 Subject: [PATCH 10/13] Fix issue with trailing slashes in MacOS (#292) * Fix issue with trailing slashes in MacOS --- restapi.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/restapi.go b/restapi.go index f4ffaf1..a54dfe8 100644 --- a/restapi.go +++ b/restapi.go @@ -1399,5 +1399,12 @@ func (s *Session) Gateway() (gateway string, err error) { } gateway = temp.URL + + // Ensure the gateway always has a trailing slash. + // MacOS will fail to connect if we add query params without a trailing slash on the base domain. + if !strings.HasSuffix(gateway, "/") { + gateway += "/" + } + return } From 5835676872d7fa65ee37b32672079c4ede2c1855 Mon Sep 17 00:00:00 2001 From: Chris Rhodes Date: Sat, 10 Dec 2016 06:47:14 -0800 Subject: [PATCH 11/13] Bump version to 0.15.0 --- discord.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/discord.go b/discord.go index cda52f3..4081c65 100644 --- a/discord.go +++ b/discord.go @@ -16,7 +16,7 @@ package discordgo import "fmt" // VERSION of Discordgo, follows Symantic Versioning. (http://semver.org/) -const VERSION = "0.14.0-dev" +const VERSION = "0.15.0" // New creates a new Discord session and will automate some startup // tasks if given enough information to do so. Currently you can pass zero From 837a3dc5294a9af91660a3d5a2b1749a5d2ee39d Mon Sep 17 00:00:00 2001 From: John Date: Tue, 28 Mar 2017 08:55:53 -0500 Subject: [PATCH 12/13] Fix README format (#344) --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index e5cbdea..f4466b1 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,7 @@ DiscordGo ==== + [![GoDoc](https://godoc.org/github.com/bwmarrin/discordgo?status.svg)](https://godoc.org/github.com/bwmarrin/discordgo) [![Go report](http://goreportcard.com/badge/bwmarrin/discordgo)](http://goreportcard.com/report/bwmarrin/discordgo) [![Build Status](https://travis-ci.org/bwmarrin/discordgo.svg?branch=master)](https://travis-ci.org/bwmarrin/discordgo) [![Discord Gophers](https://img.shields.io/badge/Discord%20Gophers-%23discordgo-blue.svg)](https://discord.gg/0f1SbxBZjYoCtNPP) [![Discord API](https://img.shields.io/badge/Discord%20API-%23go_discordgo-blue.svg)](https://discord.gg/0SBTUU1wZTWT6sqd) From d8f81e54bb594a17281e9b52d7d58d2ada9f8443 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20K=C3=B6ppl?= Date: Sat, 29 Apr 2017 23:21:10 +0200 Subject: [PATCH 13/13] Fix typo It is called 'Semantic Versioning' --- discord.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/discord.go b/discord.go index 4081c65..c8b7f0c 100644 --- a/discord.go +++ b/discord.go @@ -15,7 +15,7 @@ package discordgo import "fmt" -// VERSION of Discordgo, follows Symantic Versioning. (http://semver.org/) +// VERSION of Discordgo, follows Semantic Versioning. (http://semver.org/) const VERSION = "0.15.0" // New creates a new Discord session and will automate some startup