discordmuffin/examples/dm_pingpong/README.md
chanbakjsd 8dc42757be
Add ping pong example for direct messages (#882)
This commit adds an example on sending direct messages as it's a
frequently asked question.
The example sends a "Pong" response through DM when a user sends "ping"
in any channel the bot has the permission to see.

The example is simply adopted from the ping pong example.
2021-05-14 22:34:46 -04:00

43 lines
1 KiB
Markdown

<img align="right" src="http://bwmarrin.github.io/discordgo/img/discordgo.png">
## DiscordGo Direct Message Ping Pong Example
This example demonstrates how to utilize DiscordGo to create a Ping Pong Bot
that sends the response through Direct Message.
This Bot will respond to "ping" in any server it's in with "Pong!" in the
sender's DM.
**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 dm_pingpong example folder, run the below command to compile the
example.
```sh
go build
```
### Usage
This example uses bot tokens for authentication only. While user/password is
supported by DiscordGo, it is not recommended for bots.
```
./dm_pingpong --help
Usage of ./dm_pingpong:
-t string
Bot Token
```
The below example shows how to start the bot
```sh
./dm_pingpong -t YOUR_BOT_TOKEN
Bot is now running. Press CTRL-C to exit.
```