Skip to content

Commit f714dd0

Browse files
committed
docs: readme overhaul
1 parent e4acb29 commit f714dd0

File tree

1 file changed

+94
-30
lines changed

1 file changed

+94
-30
lines changed

README.md

Lines changed: 94 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,123 @@
1-
# [Top.gg](https://top.gg) Ruby
1+
# Top.gg Ruby SDK
22

3-
The Top.gg Ruby SDK is a lighweight package, that allows you
4-
to fetch data from the top.gg api and post data such as statistics to the website.
3+
The community-maintained Ruby library for Top.gg.
54

6-
It provides you with numerous methods to interact with the API.
5+
## Installation
76

8-
## Dependencies
7+
```sh
8+
$ gem install topgg
9+
```
910

10-
- Ruby
11+
## Setting up
1112

12-
## Installation
13+
```rb
14+
require "topgg"
1315

14-
```bash
16+
client = Topgg.new(ENV["TOPGG_TOKEN"])
17+
```
1518

16-
gem install topgg
19+
## Usage
1720

21+
### Getting a bot
22+
23+
```rb
24+
bot = client.get_bot("264811613708746752")
1825
```
1926

20-
## Note
27+
### Getting several bots
2128

22-
You require a Token to interact with the Api.
23-
The token can be found at `https://top.gg/bot/[YOUR_BOT_ID]/webhooks`
29+
```rb
30+
bots = client.get_bots({ sort: "date", limit: 50, offset: 0 })
2431

25-
## Example
32+
for bot in bots.results do
33+
puts bot.username
34+
```
2635

27-
Here's a straightforward example of how to request data with the wrapper.
36+
### Getting your bot's voters
2837

29-
```ruby
30-
require "topgg"
38+
#### First page
3139

32-
client = Topgg.new("AUTH_TOKEN", "BOTID")
40+
```rb
41+
voters = client.get_votes
3342

34-
client.get_bot("1234").avatar
35-
# returns
36-
# "https://cdn.discordapp.com/avatars/661200758510977084/4354318859c319c7ca39753260fdd350.png?size=4096"
43+
for voter in voters.results do
44+
puts voter.username
3745
```
3846

39-
### Auto Posting
47+
#### Subsequent pages
4048

41-
The library provides you with autoposting functionality, and autoposts at an interval of 15 minutes.
42-
Here's how you can use it
49+
```rb
50+
voters = client.get_votes(2)
4351

44-
```ruby
45-
require "topgg"
52+
for voter in voters.results do
53+
puts voter.username
54+
```
55+
56+
### Check if a user has voted for your bot
57+
58+
```rb
59+
has_voted = client.voted?("661200758510977084")
60+
```
61+
62+
### Getting your bot's server count
63+
64+
```rb
65+
stats = client.get_stats
66+
server_count = client.server_count
67+
```
68+
69+
### Posting your bot's server count
70+
71+
```rb
72+
client.post_stats(bot.server_count)
73+
```
74+
75+
### Automatically posting your bot's server count every few minutes
76+
77+
For Discordrb:
78+
79+
```rb
4680
require "discordrb"
4781

48-
bot = Discordrb::Bot.new token: "TOKEN"
82+
bot = Discordrb::Bot.new(token: env["BOT_TOKEN"], intents: [:servers])
4983

50-
client = Topgg.new("AUTH_TOKEN", "BOTID")
5184
bot.ready do |event|
52-
client.auto_post_stats(bot) # The discordrb bot client.
85+
client.auto_post_stats(bot)
86+
87+
puts "Bot is now ready!"
5388
end
89+
5490
bot.run
5591
```
5692

57-
# Documentation
93+
### Checking if the weekend vote multiplier is active
94+
95+
```rb
96+
is_weekend = client.is_weekend?
97+
```
98+
99+
### Generating widget URLs
100+
101+
#### Large
102+
103+
```rb
104+
widget_url = Dbl::Widget.large(:discord_bot, "574652751745777665")
105+
```
106+
107+
#### Votes
108+
109+
```rb
110+
widget_url = Dbl::Widget.votes(:discord_bot, "574652751745777665")
111+
```
112+
113+
#### Owner
114+
115+
```rb
116+
widget_url = Dbl::Widget.owner(:discord_bot, "574652751745777665")
117+
```
118+
119+
#### Social
58120

59-
Check out the api reference [here](https://rubydoc.info/gems/topgg/)
121+
```rb
122+
widget_url = Dbl::Widget.social(:discord_bot, "574652751745777665")
123+
```

0 commit comments

Comments
 (0)