Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ewohltman/go-discordbotsgg
Go Client for https://discord.bots.gg
https://github.com/ewohltman/go-discordbotsgg
discord discordbots discordbotsgg go golang
Last synced: 30 days ago
JSON representation
Go Client for https://discord.bots.gg
- Host: GitHub
- URL: https://github.com/ewohltman/go-discordbotsgg
- Owner: ewohltman
- License: mit
- Created: 2020-03-23T19:51:15.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2020-08-12T13:38:44.000Z (over 4 years ago)
- Last Synced: 2023-07-27T22:05:56.957Z (over 1 year ago)
- Topics: discord, discordbots, discordbotsgg, go, golang
- Language: Go
- Homepage:
- Size: 43 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# go-discordbotsgg
Go Client for https://discord.bots.ggThe `go-discordbotsgg` library provides a client with built-in rate limiting
for sending requests to the `discord.bots.gg` API.The API requests and rate limits follow the specs defined in the API
documentation. You must be logged in to view the documentation:
https://discord.bots.gg/docs## Examples
### Query a specific bot
Note: An API token is not required to query the API. If you do not have an API
token, pass an empty string as the second parameter to `NewClient`.```go
httpClient := &http.Client{}client := discordbotsgg.NewClient(httpClient, "apiToken")
defer client.Close()sanitize := true
bot, _ = client.QueryBotWithContext(context.TODO(), "botID", sanitize)
fmt.Printf("Bot: %+v\n", bot)
```### Query bots with search parameters
Note: An API token is not required to query the API. If you do not have an API
token, pass an empty string as the second parameter to `NewClient`.```go
httpClient := &http.Client{}client := discordbotsgg.NewClient(httpClient, "apiToken")
defer client.Close()queryParameters := &api.QueryParameters{
Q: "botNameOrDescription",
}bots, _ := client.QueryBotsWithContext(context.TODO(), queryParameters)
fmt.Printf("Bots: %+v\n", bot)
```### Update a bot's stats
Note: An API token is required to send updates to the API.```go
httpClient := &http.Client{}client := discordbotsgg.NewClient(httpClient, "apiToken")
defer client.Close()botStatsUpdate := &api.StatsUpdate{
Stats: &api.Stats{
GuildCount: totalGuildCount,
ShardCount: totalShardCount,
},
}botStatsResponse, _ := client.UpdateWithContext(context.TODO(), "botID", botStatsUpdate)
fmt.Printf("Update bot response: %s\n", botStatsResponse)
```