Skip to content
This repository has been archived by the owner. It is now read-only.
No description, website, or topics provided.
Branch: master
Clone or download
Latest commit 8287fb5 Aug 9, 2018
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
README.md Update README.md Aug 9, 2018
Structures.go Update with widget in readme and code May 8, 2018
dbl.go Update with widget in readme and code May 8, 2018

README.md

DblGo

The official API wrapper for Discord Bots API.

Installation

go get github.com/DiscordBotList/dblgo

Set-Up

Build the client for DiscordBots API

var token string =  ...;  // Your discordbots.org token
var id string =  ...;  // Your bot id

s  := dblgo.NewDBL(token, id)

Note

The GetBotsQuery is the only structure that is used as an input. The others are not supposed to be put into an function.

Methods

func PostStats

func (c *Client) PostStats(serverCount int) error

PostStats is used to post bot stats without shards to DBL

Example
// Replace 1935 with you own server count
err := s.PostStats(1935)

func PostStatsSharded

func (c *Client) PostStatsSharded(serverCount, shardID, shardCount int) error

PostStatsSharded is used to post bot stats with shards to DBL

Example
// Replace 776 with you own sever count, 1 with the shard id and, 2 with the your total amount of shards
err := s.PostStatsSharded(776, 1, 2)

func GetStats

func (c *Client) GetStats(botID int) (*BotStats, error)

GetStats Used for fetching stats for a bot

Example
// Replace 348205766127124480 with the bot id you want to find the stats of
res, err := s.GetStats(348205766127124480)

func GetBot

func (c *Client) GetBot(botID int) (*Bots, error)

GetBot used for fetching a certain bot

Example
// Replace 348205766127124480 with the bot id you want to find info about
res, err := s.GetBot(348205766127124480)

func GetUser

func (c *Client) GetUser(userID int) (*User, error)

GetUser used for finding info about a user

Example
// Replace 220271040658407424 with the user id you want to find info about
res, err := s.GetUser(220271040658407424)

func GetBots

func (c *Client) GetBots(options GetBotsQuery) (*Results, error)

GetBots is used to find bots

Example
// Replace Limit & Offset with whatever number lower than 500
q := dblgo.GetBotsQuery{
    Limit:  2,
    Offset: 1,
}
    
res, err := s.GetBots(q)

func GetVotes

func (c *Client) GetVotes() (*Votes, error)

GetVotes is used to find the votes for your bot

Example
// Replace Limit & Offset with whatever number lower than 500
res, err := s.GetVotes()

func HasVoted

func (c *Client) HasVoted(userID int) (bool, error)

HasVoted is used to check if a user has voted

Example
// Replace 220271040658407424 with the id of the user you want to check
res, err := s.HasVoted(220271040658407424)

Widget

Large Widget

func LargeWidget

func (c *Client) LargeWidget() *LargeWidget

LargeWidget creates a large widget

Example
widget := s.LargeWidget()

func TopColor

func (widget *LargeWidget) TopColor(hex string) *LargeWidget

TopColor sets the top color of the big widget

Example
// Replace these hex colors with whatever you want
widget := s.LargeWidget().TopColor("#4286f4")

func MiddleColor

func (widget *LargeWidget) MiddleColor(hex string) *LargeWidget

MiddleColor sets the middle color of the big widget

Example
// Replace these hex colors with whatever you want
widget := s.LargeWidget().TopColor("#4286f4").MiddleColor("#3c0cce")

func UsernameColor

func (widget *LargeWidget) UsernameColor(hex string) *LargeWidget

UsernameColor sets the username color of the big widget

Example
// Replace these hex colors with whatever you want
widget := s.LargeWidget().TopColor("#4286f4").MiddleColor("#3c0cce").UsernameColor("#42ce0b")

func CertifiedColor

func (widget *LargeWidget) CertifiedColor(hex string) *LargeWidget

CertifiedColor sets the certified color of the big widget

Example
// Replace these hex colors with whatever you want
widget := s.LargeWidget().TopColor("#4286f4").MiddleColor("#3c0cce").UsernameColor("#42ce0b").CertifiedColor("#ce3b0a")

func DataColor

func (widget *LargeWidget) DataColor(hex string) *LargeWidget

DataColor sets the data color of the big widget

Example
// Replace these hex colors with whatever you want
widget := s.LargeWidget().TopColor("#4286f4").MiddleColor("#3c0cce").UsernameColor("#42ce0b").CertifiedColor("#ce3b0a").DataColor("#c409ce")

func LabelColor

func (widget *LargeWidget) LabelColor(hex string) *LargeWidget

LabelColor sets the label color of the big widget

Example
// Replace these hex colors with whatever you want
widget := s.LargeWidget().TopColor("#4286f4").MiddleColor("#3c0cce").UsernameColor("#42ce0b").CertifiedColor("#ce3b0a").DataColor("#c409ce").LabelColor("#ce0909")

func HighLightColor

func (widget *LargeWidget) HighLightColor(hex string) *LargeWidget

HighLightColor sets the highlight color of the big widget

Example
// Replace these hex colors with whatever you want
widget := s.LargeWidget().TopColor("#4286f4").MiddleColor("#3c0cce").UsernameColor("#42ce0b").CertifiedColor("#ce3b0a").DataColor("#c409ce").LabelColor("#ce0909").HighLightColor("#09cea6")

func Build

func (widget *LargeWidget) Build(id string) string

Build is used to build the big widget

Example
// Replace these hex colors with whatever you want and the id with your bots id
widget := s.LargeWidget().TopColor("#4286f4").MiddleColor("#3c0cce").UsernameColor("#42ce0b").CertifiedColor("#ce3b0a").DataColor("#c409ce").LabelColor("#ce0909").HighLightColor("#09cea6").Build("348205766127124480")

All of this generates this widget

Widget

Small Widget

func SmallWidget

func (c *Client) SmallWidget() *SmallWidget

SmallWidget creates a small widget

Example
widget := s.SmallWidget()

func WidgetType

func (widget *SmallWidget) WidgetType(hex string) *SmallWidget

WidgetType sets the widget type of the small widget

Example
// Replace this type with one of those on discordbots.org
widget := s.SmallWidget().WidgetType("upvotes")

func NoAvatar

func (widget *SmallWidget) NoAvatar(avatar bool) *SmallWidget 

NoAvatar sets the avatar color of the small widget

Example
// Replace this NoAvatar with either true or false
widget := s.SmallWidget().WidgetType("upvotes").NoAvatar(true)

func AvatarBG

func (widget *SmallWidget) AvatarBG(hex string) *SmallWidget 

AvatarBG sets the avatar color of the small widget

Example
// Replace these hex colors with whatever you want
widget := s.SmallWidget().WidgetType("upvotes").NoAvatar(true).AvatarBG("#09cea6")

func LeftColor

func (widget *SmallWidget) LeftColor(hex string) *SmallWidget

LeftColor sets the left color of the small widget

Example
// Replace these hex colors with whatever you want
widget := s.SmallWidget().WidgetType("upvotes").NoAvatar(true).AvatarBG("#09cea6").LeftColor("#7509ce")

func RightColor

func (widget *SmallWidget) RightColor(hex string) *SmallWidget

RightColor sets the right color of the small widget

Example
// Replace these hex colors with whatever you want
widget := s.SmallWidget().WidgetType("upvotes").NoAvatar(true).AvatarBG("#09cea6").LeftColor("#7509ce").RightColor("#ce098f")

func LeftTextColor

func (widget *SmallWidget) LeftTextColor(hex string) *SmallWidget

LeftTextColor sets the left text color of the small widget

Example
// Replace these hex colors with whatever you want
widget := s.SmallWidget().WidgetType("upvotes").NoAvatar(true).AvatarBG("#09cea6").LeftColor("#7509ce").RightColor("#ce098f").LeftTextColor("#ce0944")

func RightTextColor

func (widget *SmallWidget) RightTextColor(hex string) *SmallWidget

RightTextColor sets the right text color of the small widget

Example
// Replace these hex colors with whatever you want
widget := s.SmallWidget().WidgetType("upvotes").NoAvatar(true).AvatarBG("#09cea6").LeftColor("#7509ce").RightColor("#ce098f").LeftTextColor("#ce0944").RightTextColor("#ce8f09")

func Build

func (widget *SmallWidget) Build(id string) string

Build is used to build the small widget

Example
// Replace these hex colors with whatever you want and the id with your bots id
widget := s.SmallWidget().WidgetType("upvotes").NoAvatar(true).AvatarBG("#09cea6").LeftColor("#7509ce").RightColor("#ce098f").LeftTextColor("#ce0944").RightTextColor("#ce8f09").Build("348205766127124480")

All of this generates this widget

Widget

Structures

BotStats Structure

type BotStats struct {
	ServerCount int      `json:"server_count"`
	Shards      []uint64 `json:"shards"`
	ShardCount  int      `json:"shard_count"`
}

Bots Structure

type Bots struct {
	DefAvatar     string   `json:"defAvatar"`
	Invite        string   `json:"invite"`
	Website       string   `json:"website"`
	Longdesc      string   `json:"longdesc"`
	Shortdesc     string   `json:"shortdesc"`
	Prefix        string   `json:"prefix"`
	Lib           string   `json:"lib"`
	Clientid      string   `json:"clientid"`
	Avatar        string   `json:"avatar"`
	ID            string   `json:"id"`
	Discriminator string   `json:"discriminator"`
	Username      string   `json:"username"`
	Date          string   `json:"date"`
	ServerCount   uint64   `json:"server_count"`
	Guilds        []string `json:"guilds"`
	Shards        []uint64 `json:"shards"`
	GitHub        string   `json:"github"`
	Support       string   `json:"support"`
	Vanity        string   `json:"vanity"`
	MonthlyPoints int      `json:"monthlyPoints"`
	Points        int      `json:"points"`
	CertifiedBot  bool     `json:"certifiedBot"`
	Owners        []string `json:"owners"`
	Tags          []string `json:"tags"`
	Legacy        bool     `json:"legacy"`
}

User Structure

type User struct {
	DefAvatar     string `json:"defAvatar"`
	Avatar        string `json:"avatar"`
	ID            string `json:"id"`
	Discriminator string `json:"discriminator"`
	Username      string `json:"username"`
	Artist        bool   `json:"artist"`
	Banner        string `json:"banner"`
	Bio           string `json:"bio"`
	Color         string `json:"color"`
	Admin         bool   `json:"admin"`
	WebMod        bool   `json:"webMod"`
	Mod           bool   `json:"mod"`
	CertifiedDev  bool   `json:"certifiedDev"`
	Supporter     bool   `json:"supporter"`
	Social        Social `json:"social"`
}

type Social struct {
	Github    string `json:"github"`
	Instagram string `json:"instagram"`
	Reddit    string `json:"reddit"`
	Twitter   string `json:"twitter"`
	Youtube   string `json:"youtube"`
}

Results Structure

type Results struct {
	AllBots []Bots `json:"results"`
}

Votes Structure

type Votes []Users

type Users struct {
	Username      string `json:"username"`
	Discriminator string `json:"discriminator"`
	ID            string `json:"id"`
	Avatar        string `json:"avatar"`
}

Authors

  • TurtleGamingFTW#4822
You can’t perform that action at this time.