gamer

package module
v0.7.1 Latest Latest
Warning

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

Go to latest
Published: Dec 30, 2020 License: MIT Imports: 6 Imported by: 0

README

gamer

Provides Discord Activity generators, as well as a shuffling Queue, for Snart.

Documentation

Overview

Package gamer provides Activity generators.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Gamer

type Gamer = func() discord.Activity

Gamer is a closure that generates an Activity.

func Static

func Static(a discord.Activity) Gamer

Static makes a Gamer that just returns the given Activity.

func Uptime

func Uptime() Gamer

Uptime makes a Gamer that shows the duration since its creation.

type Queue

type Queue []Gamer

Queue provides a pseudo-random less-recently-used queue of Gamers.

func (Queue) Cycle

func (q Queue) Cycle(u StatusUpdater, dur time.Duration)

Cycle continually calls UpdateStatus using Random, on an interval.

You'll probably want to pass a Gateway for u. 12 seconds seems to be a good minimum interval.

func (Queue) Random

func (q Queue) Random() discord.Activity

Random calls Select on a pseudo-random index in [0, (len(q) + 1) / 2).

func (Queue) Select

func (q Queue) Select(i int) discord.Activity

Select calls the Gamer at position i in the Queue, updating the order accordingly.

type StatusUpdater added in v0.5.0

type StatusUpdater interface {
	UpdateStatus(gateway.UpdateStatusData) error
}

StatusUpdater updates status. A Gateway implements this.

Jump to

Keyboard shortcuts

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