topservers

package
v1.4.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 18, 2018 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Command = &commands.YAGCommand{
	Cooldown:    5,
	CmdCategory: commands.CategoryFun,
	Name:        "TopServers",
	Description: "Responds with the top 15 servers I'm on",

	RunFunc: func(data *dcmd.Data) (interface{}, error) {
		state := bot.State
		state.RLock()

		guilds := make([]*discordgo.Guild, len(state.Guilds))
		i := 0
		for _, v := range state.Guilds {
			state.RUnlock()
			guilds[i] = v.LightCopy(true)
			state.RLock()
			i++
		}
		state.RUnlock()

		sortable := GuildsSortUsers(guilds)
		sort.Sort(sortable)

		out := "```"
		for k, v := range sortable {
			if k > 14 {
				break
			}

			out += fmt.Sprintf("\n#%-2d: %-25s (%d members)", k+1, v.Name, v.MemberCount)
		}
		return "Top servers the bot is on (by membercount):\n" + out + "\n```", nil
	},
}

Functions

This section is empty.

Types

type GuildsSortUsers

type GuildsSortUsers []*discordgo.Guild

func (GuildsSortUsers) Len

func (g GuildsSortUsers) Len() int

func (GuildsSortUsers) Less

func (g GuildsSortUsers) Less(i, j int) bool

Less reports whether the element with index i should sort before the element with index j.

func (GuildsSortUsers) Swap

func (g GuildsSortUsers) Swap(i, j int)

Swap swaps the elements with indexes i and j.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL