discord

package
v1.9.1 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2021 License: GPL-3.0 Imports: 9 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidCommandUsage = errors.New("Invalid command message")
)

Static response errors

Functions

func DefaultEmbedFooter

func DefaultEmbedFooter(text string) *discordgo.MessageEmbedFooter

DefaultEmbedFooter returns a new footer with the bots icon and optional text

func FormatTimeDefault

func FormatTimeDefault(t time.Time) string

FormatTimeDefault formats the time into a readable version of ISO8601

Types

type Argument

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

A Argument is a argument for a command parsed from a discord message

func (*Argument) ChannelID

func (a *Argument) ChannelID() (string, bool)

ChannelID returns the argument as a channelid

func (*Argument) Int

func (a *Argument) Int() (int, error)

Int returns the argument as an int

func (*Argument) RoleID

func (a *Argument) RoleID() (string, bool)

RoleID returns the argument as a roleid

func (*Argument) String

func (a *Argument) String() string

String returns the raw input argument

func (*Argument) UserID

func (a *Argument) UserID() (string, bool)

UserID returns the argument as an userid

type Arguments

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

Arguments contains multiple arguments

func ParseArguments

func ParseArguments(raw string) *Arguments

ParseArguments splits a string into multiple arguments

func (*Arguments) Get

func (a *Arguments) Get(i int) *Argument

Get returns a single argument

func (*Arguments) Len

func (a *Arguments) Len() int

Len returns the number of all arguments

func (*Arguments) Next

func (a *Arguments) Next() bool

Next returns true while arguments still contains arguments

func (*Arguments) PopFirst

func (a *Arguments) PopFirst() *Argument

PopFirst splits off the first argument from the argument list and returns it

type Command

type Command struct {
	Name        string
	Description string
	Usage       string
	Example     string
	Permissions []string
	Execute     func(*Session, *MessageCreate, *Arguments) error
}

A Command is a command of a module that responds to a user calling it

type Embed

type Embed discordgo.MessageEmbed

Embed is a discordgo embed

func NewEmbed

func NewEmbed(title, description string) *Embed

NewEmbed creates a new embed

type EmbedAuthor

type EmbedAuthor struct {
	URL          string
	Name         string
	IconURL      string
	ProxyIconURL string
}

type EmbedField

type EmbedField struct {
	Name   string
	Value  string
	Inline bool
}

type EmbedFooter

type EmbedFooter struct {
	Text         string
	IconURL      string
	ProxyIconURL string
}

type EmbedImage

type EmbedImage struct {
	URL      string
	ProxyURL string
	Width    int
	Height   int
}

type EmbedProvider

type EmbedProvider struct {
	URL  string
	Name string
}

type EmbedThumbnail

type EmbedThumbnail struct {
	URL      string
	ProxyURL string
	Width    int
	Height   int
}

type EmbedType

type EmbedType interface{}

type EmbedVideo

type EmbedVideo struct {
	URL    string
	Width  int
	Height int
}

type EventType

type EventType uint8

EventType is a discord api event

const (
	EventTypeChannelCreate EventType = iota
	EventTypeChannelUpdate
	EventTypeChannelDelete
	EventTypeChannelPinsUpdate
	EventTypeGuildCreate
	EventTypeGuildUpdate
	EventTypeGuildDelete
	EventTypeGuildBanAdd
	EventTypeGuildBanRemove
	EventTypeGuildEmojisUpdate
	EventTypeGuildIntegrationsUpdate
	EventTypeGuildMemberAdd
	EventTypeGuildMemberRemove
	EventTypeGuildMemberUpdate
	EventTypeGuildRoleCreate
	EventTypeGuildRoleDelete
	EventTypeInviteCreate
	EventTypeInviteDelete
	EventTypeMessageCreate
	EventTypeMessageUpdate
	EventTypeMessageDelete
	EventTypeMessageReactionAdd
	EventTypeMessageReactionRemove
	EventTypeMessageReactionRemoveAll
	EventTypeMessageReactionRemoveEmoji
	EventTypePresenceUpdate
	EventTypeTypingStart
	EventTypeUserUpdate
	EventTypeVoiceStateUpdate
	EventTypeVoiceServerUpdate
	EventTypeWebEventsUpdate
)

All avaliable events that can be used to trigger hooks See https://discord.com/developers/docs/topics/gateway#event-names for more information about each event

type Hook

type Hook struct {
	TriggerEvent uint8
}

A Hook is an event that is triggered by a discord event

type Member

type Member struct {
	GuildID      string
	JoinedAt     string
	Nick         string
	Deaf         bool
	Mute         bool
	User         *User
	Roles        []string
	PremiumSince string
}

func (*Member) Mention

func (m *Member) Mention() string

type Message

type Message discordgo.Message

Message wraps discordgo.Message

type MessageCreate

type MessageCreate discordgo.MessageCreate

MessageCreate wraps discordgo.MessageCreate

type Module

type Module struct {
	Name        string              // The name of the module
	Description string              // Module Description
	GuildOnly   bool                // Whether the module may only be used in a guild
	Commands    map[string]*Command // All commands of the module
	Permissions []string
	Store       *store.Store
}

A Module is a namespace for creating custom commands and bot functionalities

type Session

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

Session is a discord session

func NewSession

func NewSession(s *discordgo.Session) *Session

NewSession creates a new session

func (*Session) Bare

func (s *Session) Bare() *discordgo.Session

Bare returns the underlaying dgo session

func (*Session) ChannelMessageDelete

func (s *Session) ChannelMessageDelete(chID, msgID string) error

ChannelMessageDelete deletes a message in a channel

func (*Session) ChannelMessageSend

func (s *Session) ChannelMessageSend(chID string, msg ...string) error

ChannelMessageSend sends a message to a channel

func (*Session) ChannelMessageSendEmbed

func (s *Session) ChannelMessageSendEmbed(chID string, embed *Embed) (*discordgo.Message, error)

ChannelMessageSendEmbed sends a embed in a channel

func (*Session) ChannelTyping

func (s *Session) ChannelTyping(chID string) error

ChannelTyping starts typing in a channel

func (*Session) Failure

func (s *Session) Failure(chID string, msg ...string)

Failure sends a fail message to a channel

func (*Session) Guild

func (s *Session) Guild(guildID string) (*discordgo.Guild, error)

Guild returns a guild

func (*Session) GuildMember

func (s *Session) GuildMember(guildID, userID string) (*Member, error)

func (*Session) GuildMemberKick

func (s *Session) GuildMemberKick(guildID, userID string) error

GuildMemberKick kicks a user from a guild

func (*Session) GuildMemberMove

func (s *Session) GuildMemberMove(guildID, userID string, channelID *string) error

GuildMemberMove moves a guild member into another channel if channelID is nil, he is removed from all channels instead

func (*Session) GuildMemberNickname

func (s *Session) GuildMemberNickname(guildID, userID, nickname string) error

func (*Session) GuildMemberRoleAdd

func (s *Session) GuildMemberRoleAdd(guildID, userID, roleID string) error

func (*Session) GuildMemberRoleRemove

func (s *Session) GuildMemberRoleRemove(guildID, userID, roleID string) error

func (*Session) InvalidCommandUsage

func (s *Session) InvalidCommandUsage() error

InvalidCommandUsage returns the error for invalid command usage

func (*Session) ReactionResponse

func (s *Session) ReactionResponse(msgStr, chID, uID string) (int, error)

ReactionResponse sends a number of reactions and waits for the user to add one It then returns the number of the reaction added

func (*Session) Respond

func (s *Session) Respond(chID, uID string, msg ...string) error

Respond reponds to a user in the format of `<@uID>, msg` chID is the channel id to send the message uID is the user id to mention msg is a string array for the message to be send

func (*Session) Success

func (s *Session) Success(chID string, msg ...string)

Success sends a success message to a channel

func (*Session) UserChannelCreate

func (s *Session) UserChannelCreate(userID string) (*discordgo.Channel, error)

UserChannelCreate creates a new private channel with a user

type User

type User struct {
	ID            string
	Username      string
	Avatar        string
	Discriminator string
	Token         string
	Verified      bool
	Bot           bool

	// https://discord.com/developers/docs/resources/user#user-object-user-flags
	PublicFlags int

	PremiumType int
	System      bool
	Flags       int
}

User contains data for a discord user

func (*User) Mention

func (u *User) Mention() string

Mention returns a mention to the user

Jump to

Keyboard shortcuts

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