diff --git a/examples/new_basic/README.md b/examples/new_basic/README.md deleted file mode 100644 index b51a494..0000000 --- a/examples/new_basic/README.md +++ /dev/null @@ -1,35 +0,0 @@ - -Basic New Example -==== - -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 -DiscordGo is correctly installed on your system. - -```sh -go build -``` - -### Usage - -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: - -t string - Bot Token -``` - -The below example shows how to start the bot - -```sh -./new_basic -t YOUR_BOT_TOKEN -``` diff --git a/examples/new_basic/main.go b/examples/new_basic/main.go deleted file mode 100644 index 0191bb0..0000000 --- a/examples/new_basic/main.go +++ /dev/null @@ -1,53 +0,0 @@ -package main - -import ( - "flag" - "fmt" - "time" - - "github.com/bwmarrin/discordgo" -) - -// Variables used for command line parameters -var ( - Token string -) - -func init() { - - flag.StringVar(&Token, "t", "", "Bot Token") - flag.Parse() -} - -func main() { - - // 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 - } - - // Register messageCreate as a callback for the messageCreate events. - dg.AddHandler(messageCreate) - - // Open the websocket and begin listening. - err = dg.Open() - if err != nil { - fmt.Println("error opening connection,", err) - return - } - - fmt.Println("Bot is now running. Press CTRL-C to exit.") - // Simple way to keep program running until CTRL-C is pressed. - <-make(chan struct{}) - return -} - -// This function will be called (due to AddHandler above) every time a new -// message is created on any channel that the autenticated bot has access to. -func messageCreate(s *discordgo.Session, m *discordgo.MessageCreate) { - - // Print message to stdout. - fmt.Printf("%20s %20s %20s > %s\n", m.ChannelID, time.Now().Format(time.Stamp), m.Author.Username, m.Content) -}