forked from pothtonswer/discordmuffin
Remove obsolete examples
This commit is contained in:
parent
0d776e61a1
commit
84edff87fe
4 changed files with 0 additions and 247 deletions
|
@ -1,57 +0,0 @@
|
||||||
<img align="right" src="http://bwmarrin.github.io/discordgo/img/discordgo.png">
|
|
||||||
|
|
||||||
## DiscordGo AppMaker Example
|
|
||||||
|
|
||||||
This example demonstrates how to utilize DiscordGo to create, view, and delete
|
|
||||||
Bot Applications on your account.
|
|
||||||
|
|
||||||
These tasks are normally accomplished from the
|
|
||||||
[Discord Developers](https://discord.com/developers/applications/me) site.
|
|
||||||
|
|
||||||
**Join [Discord Gophers](https://discord.gg/0f1SbxBZjYoCtNPP)
|
|
||||||
Discord chat channel for support.**
|
|
||||||
|
|
||||||
### Build
|
|
||||||
|
|
||||||
This assumes you already have a working Go environment setup and that
|
|
||||||
DiscordGo is correctly installed on your system.
|
|
||||||
|
|
||||||
From within the appmaker example folder, run the below command to compile the
|
|
||||||
example.
|
|
||||||
|
|
||||||
```sh
|
|
||||||
go build
|
|
||||||
```
|
|
||||||
|
|
||||||
### Usage
|
|
||||||
|
|
||||||
This example only uses authentication tokens for authentication. While
|
|
||||||
user email/password is supported by DiscordGo, it is not recommended.
|
|
||||||
|
|
||||||
```
|
|
||||||
./appmaker --help
|
|
||||||
Usage of ./appmaker:
|
|
||||||
-d string
|
|
||||||
Application ID to delete
|
|
||||||
-l List Applications Only
|
|
||||||
-n string
|
|
||||||
Name to give App/Bot
|
|
||||||
-t string
|
|
||||||
Owner Account Token
|
|
||||||
```
|
|
||||||
|
|
||||||
* Account Token is required. The account will be the "owner" of any bot
|
|
||||||
applications created.
|
|
||||||
|
|
||||||
* If you provide the **-l** flag than appmaker will only display a list of
|
|
||||||
applications on the provided account.
|
|
||||||
|
|
||||||
* If you provide a **-d** flag with a valid application ID then that application
|
|
||||||
will be deleted.
|
|
||||||
|
|
||||||
Below example will create a new Bot Application under the given account.
|
|
||||||
The Bot will be named **DiscordGoRocks**
|
|
||||||
|
|
||||||
```sh
|
|
||||||
./appmaker -t YOUR_USER_TOKEN -n DiscordGoRocks
|
|
||||||
```
|
|
|
@ -1,103 +0,0 @@
|
||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"encoding/json"
|
|
||||||
"flag"
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"github.com/bwmarrin/discordgo"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Variables used for command line options
|
|
||||||
var (
|
|
||||||
Token string
|
|
||||||
Name string
|
|
||||||
DeleteID string
|
|
||||||
ListOnly bool
|
|
||||||
)
|
|
||||||
|
|
||||||
func init() {
|
|
||||||
|
|
||||||
flag.StringVar(&Token, "t", "", "Owner Account Token")
|
|
||||||
flag.StringVar(&Name, "n", "", "Name to give App/Bot")
|
|
||||||
flag.StringVar(&DeleteID, "d", "", "Application ID to delete")
|
|
||||||
flag.BoolVar(&ListOnly, "l", false, "List Applications Only")
|
|
||||||
flag.Parse()
|
|
||||||
|
|
||||||
if Token == "" {
|
|
||||||
flag.Usage()
|
|
||||||
os.Exit(1)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func main() {
|
|
||||||
|
|
||||||
var err error
|
|
||||||
|
|
||||||
// Create a new Discord session using the provided login information.
|
|
||||||
dg, err := discordgo.New(Token)
|
|
||||||
if err != nil {
|
|
||||||
fmt.Println("error creating Discord session,", err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// If -l set, only display a list of existing applications
|
|
||||||
// for the given account.
|
|
||||||
if ListOnly {
|
|
||||||
|
|
||||||
aps, err := dg.Applications()
|
|
||||||
if err != nil {
|
|
||||||
fmt.Println("error fetching applications,", err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, v := range aps {
|
|
||||||
fmt.Println("-----------------------------------------------------")
|
|
||||||
b, _ := json.MarshalIndent(v, "", " ")
|
|
||||||
fmt.Println(string(b))
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// if -d set, delete the given Application
|
|
||||||
if DeleteID != "" {
|
|
||||||
err = dg.ApplicationDelete(DeleteID)
|
|
||||||
if err != nil {
|
|
||||||
fmt.Println("error deleting application,", err)
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if Name == "" {
|
|
||||||
flag.Usage()
|
|
||||||
os.Exit(1)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create a new application.
|
|
||||||
ap := &discordgo.Application{}
|
|
||||||
ap.Name = Name
|
|
||||||
ap, err = dg.ApplicationCreate(ap)
|
|
||||||
if err != nil {
|
|
||||||
fmt.Println("error creating new application,", err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
fmt.Printf("Application created successfully:\n")
|
|
||||||
b, _ := json.MarshalIndent(ap, "", " ")
|
|
||||||
fmt.Println(string(b))
|
|
||||||
|
|
||||||
// Create the bot account under the application we just created
|
|
||||||
bot, err := dg.ApplicationBotCreate(ap.ID)
|
|
||||||
if err != nil {
|
|
||||||
fmt.Println("error creating bot account,", err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
fmt.Printf("Bot account created successfully.\n")
|
|
||||||
b, _ = json.MarshalIndent(bot, "", " ")
|
|
||||||
fmt.Println(string(b))
|
|
||||||
|
|
||||||
fmt.Println("Please save the above posted info in a secure place.")
|
|
||||||
fmt.Println("You will need that information to login with your bot account.")
|
|
||||||
}
|
|
|
@ -1,47 +0,0 @@
|
||||||
<img align="right" src="http://bwmarrin.github.io/discordgo/img/discordgo.png">
|
|
||||||
|
|
||||||
## DiscordGo MyToken Example
|
|
||||||
|
|
||||||
This example demonstrates how to utilize DiscordGo to login with an email and
|
|
||||||
password then to print out the Authentication Token for that user's account.
|
|
||||||
|
|
||||||
Everytime this application is run a new authentication token is generated
|
|
||||||
for your account. Logging you in via email and password then creating a new
|
|
||||||
token is a cpu/mem expensive task for Discord. Because of that, it is highly
|
|
||||||
recommended to avoid doing this very often. Please only use this once to get a
|
|
||||||
token for your use and then always just your token.
|
|
||||||
|
|
||||||
**Join [Discord Gophers](https://discord.gg/0f1SbxBZjYoCtNPP)
|
|
||||||
Discord chat channel for support.**
|
|
||||||
|
|
||||||
### Build
|
|
||||||
|
|
||||||
This assumes you already have a working Go environment setup and that
|
|
||||||
DiscordGo is correctly installed on your system.
|
|
||||||
|
|
||||||
From within the mytoken example folder, run the below command to compile the
|
|
||||||
example.
|
|
||||||
|
|
||||||
```sh
|
|
||||||
go build
|
|
||||||
```
|
|
||||||
|
|
||||||
### Usage
|
|
||||||
|
|
||||||
You must authenticate using both Email and Password for an account.
|
|
||||||
|
|
||||||
```
|
|
||||||
./mytoken --help
|
|
||||||
Usage of ./mytoken:
|
|
||||||
-e string
|
|
||||||
Account Email
|
|
||||||
-p string
|
|
||||||
Account Password
|
|
||||||
```
|
|
||||||
|
|
||||||
The below example shows how to start the program using an Email and Password for
|
|
||||||
authentication.
|
|
||||||
|
|
||||||
```sh
|
|
||||||
./mytoken -e youremail@here.com -p MySecretPassword
|
|
||||||
```
|
|
|
@ -1,40 +0,0 @@
|
||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"flag"
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"github.com/bwmarrin/discordgo"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Variables used for command line parameters
|
|
||||||
var (
|
|
||||||
Email string
|
|
||||||
Password string
|
|
||||||
)
|
|
||||||
|
|
||||||
func init() {
|
|
||||||
|
|
||||||
flag.StringVar(&Email, "e", "", "Account Email")
|
|
||||||
flag.StringVar(&Password, "p", "", "Account Password")
|
|
||||||
flag.Parse()
|
|
||||||
|
|
||||||
if Email == "" || Password == "" {
|
|
||||||
flag.Usage()
|
|
||||||
os.Exit(1)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func main() {
|
|
||||||
|
|
||||||
// Create a new Discord session using the provided login information.
|
|
||||||
dg, err := discordgo.New(Email, Password)
|
|
||||||
if err != nil {
|
|
||||||
fmt.Println("error creating Discord session,", err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// Print out your token.
|
|
||||||
fmt.Printf("Your Authentication Token is:\n\n%s\n", dg.Token)
|
|
||||||
}
|
|
Loading…
Reference in a new issue