gocord

package module
v0.0.0-...-0b0b1ae Latest Latest
Warning

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

Go to latest
Published: Jun 15, 2021 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var EVENTS = struct {
	READY               string
	MESSAGE_CREATE      string
	CHANNEL_CREATE      string
	CHANNEL_UPDATE      string
	CHANNEL_DELETE      string
	GUILD_BAN_ADD       string
	GUILD_BAN_REMOVE    string
	GUILD_MEMBER_ADD    string
	GUILD_MEMBER_REMOVE string
	GUILD_MEMBER_UPDATE string
}{
	"READY",
	"MESSAGE_CREATE",
	"CHANNEL_CREATE",
	"CHANNEL_UPDATE",
	"CHANNEL_DELETE",
	"GUILD_BAN_ADD",
	"GUILD_BAN_REMOVE",
	"GUILD_MEMBER_ADD",
	"GUILD_MEMBER_REMOVE",
	"GUILD_MEMBER_UPDATE",
}
View Source
var ErrCannotRead = fmt.Errorf("failed to read gateway message")
View Source
var ErrClientCreate = fmt.Errorf("an error occurred while instantiating the client")
View Source
var ErrConnFailed = fmt.Errorf("failed to connect to gateway")
View Source
var ErrDecompressEvent = fmt.Errorf("failed to decompress event message")
View Source
var ErrEventDecode = fmt.Errorf("failed to decode even message")
View Source
var ErrExpectedHello = fmt.Errorf("gateway returned non-hello response")
View Source
var ErrHeartbeat = fmt.Errorf("failed to send heartbeat")
View Source
var ErrNoGateway = fmt.Errorf("failed to get gateway uri")
View Source
var Intents = struct {
	GUILDS                   int
	GUILD_MEMBERS            int
	GUILD_BANS               int
	GUILD_EMOJIS             int
	GUILD_INTEGRATIONS       int
	GUILD_WEBHOOKS           int
	GUILD_INVITES            int
	GUILD_VOICE_STATES       int
	GUILD_PRESENCES          int
	GUILD_MESSAGES           int
	GUILD_MESSAGE_REACTIONS  int
	GUILD_MESSAGE_TYPING     int
	DIRECT_MESSAGES          int
	DIRECT_MESSAGE_REACTIONS int
	DIRECT_MESSAGE_TYPING    int
	ALL                      int
}{
	1 << 0, 1 << 1, 1 << 2,
	1 << 3, 1 << 4, 1 << 5,
	1 << 6, 1 << 7, 1 << 8,
	1 << 9, 1 << 10, 1 << 11,
	1 << 12, 1 << 13, 1 << 14,
	1 << 0 & 1 << 1 & 1 << 2 & 1 << 3 & 1 << 4 & 1 << 5 & 1 << 6 & 1 << 7 & 1 << 8 & 1 << 9 & 1 << 10 & 1 << 11 & 1 << 12 & 1 << 13 & 1 << 14,
}

Functions

func GetEventName

func GetEventName(eName string) string

really fucking unreadable :D

Types

type Author

type Author struct {
	Bot bool `json:"bot"`
	User
}

type Channel

type Channel struct {
	ID     string `json:"id"`
	Name   string `json:"name"`
	NSFW   bool   `json:"nsfw"`
	Client *Client
}

func (*Channel) SendEmbed

func (c *Channel) SendEmbed(embed Embed) error

func (*Channel) SendMessage

func (c *Channel) SendMessage(message string) error

Sends a message to a specified channel.

type Client

type Client struct {
	Options Options

	User User `json:"user"`
	// contains filtered or unexported fields
}

func New

func New(options Options) (c *Client, err error)

Creates the client and allows us to access methods to interact with Discord.

func (*Client) Call

func (c *Client) Call(event string, ctx *Context)

Exported call function. User can run their own events.

func (*Client) Close

func (c *Client) Close()

Closes the current websocket connection with Discord.

func (*Client) Connect

func (c *Client) Connect() error

Opens a websocket connection with Discord.

func (*Client) On

func (c *Client) On(event string, ev EventFunc)

Creates an event listener to listen for the specified event.

type Context

type Context struct {
	Type string
	/* Only exists on messageCreate */
	Message *Message
	/* Should always exist */
	Client *Client
	/* Exists in channel create and delete */
	Channel *Channel
	/* Exists on member join, leave and update */
	Member *Member
}

type Embed

type Embed struct {
	Title       string         `json:"title"`
	Type        string         `json:"type"`
	Description string         `json:"description"`
	URL         string         `json:"url"`
	Timestamp   time.Time      `json:"timestamp"`
	Color       int            `json:"color"`
	Footer      EmbedFooter    `json:"footer"`
	Image       EmbedImage     `json:"image"`
	Thumbnail   EmbedThumbnail `json:"thumbnail"`
	Video       EmbedVideo     `json:"video"`
	Provider    EmbedProvider  `json:"provider"`
	Author      EmbedAuthor    `json:"author"`
	Fields      []EmbedFields  `json:"fields"`
}

type EmbedAuthor

type EmbedAuthor struct {
}

type EmbedFields

type EmbedFields struct {
}

type EmbedFooter

type EmbedFooter struct {
}

type EmbedImage

type EmbedImage struct {
}

type EmbedProvider

type EmbedProvider struct {
}

type EmbedThumbnail

type EmbedThumbnail struct {
}

type EmbedVideo

type EmbedVideo struct {
}

type Event

type Event struct {
	Type string          `json:"t"`
	Seq  int64           `json:"s"`
	Op   int             `json:"op"`
	Data json.RawMessage `json:"d"`

	Other interface{} `json:"-"`
}

type EventFunc

type EventFunc func(context *Context)

type Guild

type Guild struct {
	ID       string
	Channels []*Channel
	Members  []*Member
	Client   *Client
}

func (*Guild) BanMember

func (g *Guild) BanMember(memberid, reason string) error

Bans the member from the guild

func (*Guild) CreateRole

func (g *Guild) CreateRole(name, permissions string, color int, hoist, mentionable bool) error

Creates a role

func (*Guild) DeleteRole

func (g *Guild) DeleteRole(roleId string) error

Deletes a role

func (*Guild) KickMember

func (g *Guild) KickMember(memberId, reason string) error

Kicks (or removes) a member from the guild

func (*Guild) UnbanMember

func (g *Guild) UnbanMember(memberId, reason string) error

Unbans the member from the guild

type Member

type Member struct {
	User
	Guild *Guild
}

idk if member should inherit user

func (*Member) Ban

func (m *Member) Ban(reason string) error

type Message

type Message struct {
	Client    *Client
	Content   string `json:"content"`
	ID        string `json:"id"`
	ChannelID string `json:"channel_id"`
	Member    Member `json:"member"`
	User      User   `json:"user"`
	Author    Author `json:"author"`
	Channel   *Channel
	Guild     *Guild
}

type Options

type Options struct {
	Token   string
	Intents int
}

type User

type User struct {
	ID            string `json:"id"`
	Username      string `json:"username"`
	Discriminator string `json:"discriminator"`
	Bot           bool   `json:"bot"`
}

type Websocket

type Websocket struct {
	// contains filtered or unexported fields
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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