Update examples to use Bot tokens.

This commit is contained in:
Chris Rhodes 2016-10-29 16:30:07 -07:00
parent 212fc66a25
commit e37343d4d4
8 changed files with 27 additions and 60 deletions

View file

@ -21,13 +21,13 @@ cp ../src/github.com/bwmarrin/discordgo/examples/airhorn/airhorn.dca .
``` ```
Usage of ./airhorn: Usage of ./airhorn:
-t string -t string
Account Token Bot Token
``` ```
The below example shows how to start the bot. The below example shows how to start the bot.
```sh ```sh
./airhorn -t "Bot YOUR_BOT_TOKEN" ./airhorn -t YOUR_BOT_TOKEN
``` ```
### Creating sounds ### Creating sounds

View file

@ -13,7 +13,7 @@ import (
) )
func init() { func init() {
flag.StringVar(&token, "t", "", "Account Token") flag.StringVar(&token, "t", "", "Bot Token")
flag.Parse() flag.Parse()
} }
@ -34,8 +34,8 @@ func main() {
return return
} }
// Create a new Discord session using the provided token. // Create a new Discord session using the provided bot token.
dg, err := discordgo.New(token) dg, err := discordgo.New("Bot " + token)
if err != nil { if err != nil {
fmt.Println("Error creating Discord session: ", err) fmt.Println("Error creating Discord session: ", err)
return return

View file

@ -34,7 +34,7 @@ Usage of ./ocalfile:
Avatar File Name. 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 ```sh
./localfile -t "Bot YOUR_BOT_TOKEN" -f "./pathtoavatar.jpg" ./localfile -t "Bot YOUR_BOT_TOKEN" -f "./pathtoavatar.jpg"

View file

@ -34,7 +34,7 @@ Usage of ./url:
Link to the avatar image. 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 ```sh
./url -t "Bot YOUR_BOT_TOKEN" -l "http://bwmarrin.github.io/discordgo/img/discordgo.png" ./url -t "Bot YOUR_BOT_TOKEN" -l "http://bwmarrin.github.io/discordgo/img/discordgo.png"

View file

@ -3,7 +3,7 @@ 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. and print out all received chat messages.
This example uses the high level New() helper function to connect to Discord. This example uses the high level New() helper function to connect to Discord.
@ -18,30 +18,18 @@ go build
### Usage ### Usage
You must authenticate using either an Authentication Token or both Email and This example uses bot tokens for authentication only.
Password for an account. Keep in mind official Bot accounts only support While user/password is supported by DiscordGo, it is not recommended.
authenticating via Token.
``` ```
./new_basic --help ./new_basic --help
Usage of ./new_basic: Usage of ./new_basic:
-e string
Account Email
-p string
Account Password
-t string -t string
Account Token Bot Token
``` ```
The below example shows how to start the bot using an Email and Password for The below example shows how to start the bot
authentication.
```sh ```sh
./new_basic -e EmailHere -p PasswordHere ./new_basic -t YOUR_BOT_TOKEN
```
The below example shows how to start the bot using the bot user's token
```sh
./new_basic -t "Bot YOUR_BOT_TOKEN"
``` ```

View file

@ -10,24 +10,19 @@ import (
// Variables used for command line parameters // Variables used for command line parameters
var ( var (
Email string Token string
Password string
Token string
) )
func init() { func init() {
flag.StringVar(&Email, "e", "", "Account Email") flag.StringVar(&Token, "t", "", "Bot Token")
flag.StringVar(&Password, "p", "", "Account Password")
flag.StringVar(&Token, "t", "", "Account Token")
flag.Parse() flag.Parse()
} }
func main() { func main() {
// Create a new Discord session using the provided login information. // Create a new Discord session using the provided bot token.
// Use discordgo.New(Token) to just use a token for login. dg, err := discordgo.New("Bot " + Token)
dg, err := discordgo.New(Email, Password, Token)
if err != nil { if err != nil {
fmt.Println("error creating Discord session,", err) fmt.Println("error creating Discord session,", err)
return return

View file

@ -17,30 +17,18 @@ go build
### Usage ### Usage
You must authenticate using either an Authentication Token or both Email and This example uses bot tokens for authentication only.
Password for an account. Keep in mind official Bot accounts only support While user/password is supported by DiscordGo, it is not recommended.
authenticating via Token.
``` ```
./pingpong --help ./pingpong --help
Usage of ./pingpong: Usage of ./pingpong:
-e string
Account Email
-p string
Account Password
-t string -t string
Account Token Bot Token
``` ```
The below example shows how to start the bot using an Email and Password for The below example shows how to start the bot
authentication.
```sh ```sh
./pingpong -e EmailHere -p PasswordHere ./pingpong -t YOUR_BOT_TOKEN
```
The below example shows how to start the bot using the bot user's token
```sh
./pingpong -t "Bot YOUR_BOT_TOKEN"
``` ```

View file

@ -9,24 +9,20 @@ import (
// Variables used for command line parameters // Variables used for command line parameters
var ( var (
Email string Token string
Password string BotID string
Token string
BotID string
) )
func init() { func init() {
flag.StringVar(&Email, "e", "", "Account Email") flag.StringVar(&Token, "t", "", "Bot Token")
flag.StringVar(&Password, "p", "", "Account Password")
flag.StringVar(&Token, "t", "", "Account Token")
flag.Parse() flag.Parse()
} }
func main() { func main() {
// Create a new Discord session using the provided login information. // Create a new Discord session using the provided bot token.
dg, err := discordgo.New(Email, Password, Token) dg, err := discordgo.New("Bot " + Token)
if err != nil { if err != nil {
fmt.Println("error creating Discord session,", err) fmt.Println("error creating Discord session,", err)
return return