revoltgo

package module
Version: v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2021 License: MIT Imports: 11 Imported by: 0

README

Revoltgo

Revoltgo is a go package for writing bots / self-bots in revolt easily.

NOTE: This package is still under development and not finished. Create an issue if you found a bug.

NOTE 2: This package requires go 1.17.

Features

  • Multiple event listen
  • Easy to use
  • Supports self-bots
  • Simple cache system

Installation

  • Create a new project and init go.mod file. go mod init example
  • Install the package using go get github.com/5elenay/revoltgo

API Reference

Click here for api reference.

Ping Pong Example (Bot)

package main

import (
    "os"
    "os/signal"
    "syscall"

    "github.com/5elenay/revoltgo"
)

func main() {
    // Init a new client.
    client := revoltgo.Client{
        Token: "bot token",
    }

    // Listen a on message event.
    client.OnMessage(func(m *revoltgo.Message) {
        if m.Content == "!ping" {
            sendMsg := &revoltgo.SendMessage{}
            sendMsg.SetContent("🏓 Pong!")

            m.Reply(true, sendMsg)
        }
    })

    // Start the client.
    client.Start()

    // Wait for close.
    sc := make(chan os.Signal, 1)

    signal.Notify(
        sc,
        syscall.SIGINT,
        syscall.SIGTERM,
        os.Interrupt,
    )
    <-sc

    // Destroy client.
    client.Destroy()
}

Ping Pong Example (Self-Bot)

package main

import (
    "os"
    "os/signal"
    "syscall"

    "github.com/5elenay/revoltgo"
)

func main() {
    // Init a new client.
    client := revoltgo.Client{
        SelfBot: &revoltgo.SelfBot{
            Id:           "session id",
            SessionToken: "session token",
            UserId:       "user id",
        },
    }

    // Listen a on message event.
    client.OnMessage(func(m *revoltgo.Message) {
        if m.Content == "!ping" {
            sendMsg := &revoltgo.SendMessage{}
            sendMsg.SetContent("🏓 Pong!")

            m.Reply(true, sendMsg)
        }
    })

    // Start the client.
    client.Start()

    // Wait for close.
    sc := make(chan os.Signal, 1)

    signal.Notify(
        sc,
        syscall.SIGINT,
        syscall.SIGTERM,
        os.Interrupt,
    )
    <-sc

    // Destroy client.
    client.Destroy()
}

Documentation

Index

Constants

View Source
const (
	WS_URL  = "wss://ws.revolt.chat"
	API_URL = "https://api.revolt.chat"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Attachment

type Attachment struct {
	Id          string `json:"_id"`
	Tag         string `json:"tag"`
	Size        int    `json:"size"`
	FileName    string `json:"filename"`
	Metadata    *AttachmentMetadata
	ContentType string `json:"content_type"`
}

Attachment struct.

type AttachmentMetadata

type AttachmentMetadata struct {
	Type   string `json:"type"`
	Width  int    `json:"width"`
	Height int    `json:"height"`
}

Attachment metadata struct.

type Binary added in v0.1.1

type Binary struct {
	Data []byte
}

Revoltgo binary struct.

func (Binary) Save added in v0.1.1

func (b Binary) Save(path string) error

Save data to the given path.

type BotInformation

type BotInformation struct {
	Owner string `json:"owner"`
}

Bot information struct.

type Cache

type Cache struct {
	Users    []*User    `json:"users"`
	Servers  []*Server  `json:"servers"`
	Channels []*Channel `json:"channels"`
	Members  []*Member  `json:"members"`
}

Client cache struct.

func (*Cache) GetChannel

func (c *Cache) GetChannel(id string) *Channel

Get a channel from cache by Id. Will return an empty channel struct if not found.

func (*Cache) GetMember

func (c *Cache) GetMember(id string) *Member

Get a member from cache by Id. Will return an empty member struct if not found.

func (*Cache) GetServer

func (c *Cache) GetServer(id string) *Server

Get a server from cache by Id. Will return an empty server struct if not found.

func (*Cache) GetUser

func (c *Cache) GetUser(id string) *User

Get an user from cache by Id. Will return an empty user struct if not found.

func (*Cache) RemoveChannel

func (c *Cache) RemoveChannel(id string) error

Remove a channel from cache by Id. Will not delete the channel, just deletes the channel from cache. Will change the entire channel cache order!

func (*Cache) RemoveMember

func (c *Cache) RemoveMember(id string) error

Remove a member from cache by Id. Will not delete the member, just deletes the member from cache. Will change the entire member cache order!

func (*Cache) RemoveServer

func (c *Cache) RemoveServer(id string) error

Remove a server from cache by Id. Will not delete the server, just deletes the server from cache. Will change the entire server cache order!

func (*Cache) RemoveUser

func (c *Cache) RemoveUser(id string) error

Remove an user from cache by Id. Will not delete the user, just deletes the user from cache. Will change the entire user cache order!

type Channel

type Channel struct {
	Client    *Client
	CreatedAt time.Time

	Id                 string      `json:"_id"`
	ChannelType        string      `json:"channel_type"`
	UserId             string      `json:"user"`
	Nonce              string      `json:"nonce"`
	Active             bool        `json:"active"`
	Recipients         []string    `json:"recipients"`
	LastMessage        interface{} `json:"last_message"`
	Name               string      `json:"name"`
	OwnerId            string      `json:"owner"`
	Description        string      `json:"description"`
	Icon               *Attachment `json:"icon"`
	DefaultPermissions uint        `json:"default_permissions"`
	RolePermissions    interface{} `json:"role_permissions"`
	Permissions        uint        `json:"permissions"`
}

Channel struct.

func (Channel) AddGroupRecipient

func (c Channel) AddGroupRecipient(user_id string) error

Add a new group recipient. This function is only for GroupChannel.

func (*Channel) CalculateCreationDate

func (c *Channel) CalculateCreationDate() error

Calculate creation date and edit the struct.

func (Channel) CreateInvite

func (c Channel) CreateInvite() (string, error)

Create a new invite. Returns a string (invite code) and error (nil if not exists).

func (Channel) Delete

func (c Channel) Delete() error

Delete channel.

func (Channel) DeleteGroupRecipient

func (c Channel) DeleteGroupRecipient(user_id string) error

Delete a group recipient. This function is only for GroupChannel.

func (Channel) Edit

func (c Channel) Edit(ec *EditChannel) error

Edit channel.

func (Channel) FetchGroupMembers

func (c Channel) FetchGroupMembers() ([]*User, error)

Fetch all of the members from group. This function is only for GroupChannel.

func (Channel) FetchMessage

func (c Channel) FetchMessage(id string) (*Message, error)

Fetch a message from channel by Id.

func (Channel) FetchMessages

func (c Channel) FetchMessages(options map[string]interface{}) (*FetchedMessages, error)

Fetch messages from channel. Check: https://developers.revolt.chat/api/#tag/Messaging/paths/~1channels~1:channel~1messages/get for map parameters.

func (Channel) SendMessage

func (c Channel) SendMessage(message *SendMessage) (*Message, error)

Send a message to the channel.

func (Channel) SetPermissions

func (c Channel) SetPermissions(role_id string, permissions uint) error

Set channel permissions for a role. Leave role field empty if you want to edit default permissions

type Client

type Client struct {
	SelfBot *SelfBot
	Token   string
	Socket  gowebsocket.Socket
	HTTP    *http.Client
	Cache   *Cache

	// Event Functions
	OnReadyFunctions              []func()
	OnMessageFunctions            []func(message *Message)
	OnMessageUpdateFunctions      []func(channel_id, message_id string, payload map[string]interface{})
	OnMessageDeleteFunctions      []func(channel_id, message_id string)
	OnChannelCreateFunctions      []func(channel *Channel)
	OnChannelUpdateFunctions      []func(channel_id, clear string, payload map[string]interface{})
	OnChannelDeleteFunctions      []func(channel_id string)
	OnUnknownEventFunctions       []func(message string)
	OnChannelStartTypingFunctions []func(channel_id, user_id string)
	OnChannelStopTypingFunctions  []func(channel_id, user_id string)
	OnServerUpdateFunctions       []func(server_id, clear string, payload map[string]interface{})
	OnServerDeleteFunctions       []func(server_id string)
	OnServerMemberUpdateFunctions []func(server_id, clear string, payload map[string]interface{})
	OnServerMemberJoinFunctions   []func(server_id, user_id string)
	OnServerMemberLeaveFunctions  []func(server_id, user_id string)
}

Client struct.

func (Client) AddFriend added in v0.2.0

func (c Client) AddFriend(username string) (*UserRelations, error)

Send friend request. / Accept friend request. User relations struct only will have status. id is not defined for this function.

func (*Client) Auth

func (c *Client) Auth() error

Auth client user.

func (*Client) CreateGroup

func (c *Client) CreateGroup(name, description string, users []string) (*Channel, error)

Create a new group. Users parameter is a list of users will be added.

func (*Client) CreateServer

func (c *Client) CreateServer(name, description string) (*Server, error)

Create a server.

func (*Client) Destroy

func (c *Client) Destroy()

Destroy the websocket.

func (Client) Edit

func (c Client) Edit(eu *EditUser) error

Edit client user.

func (*Client) FetchChannel

func (c *Client) FetchChannel(id string) (*Channel, error)

Fetch a channel by Id.

func (*Client) FetchDirectMessages

func (c *Client) FetchDirectMessages() ([]*Channel, error)

Fetch all of the DMs.

func (Client) FetchRelationships added in v0.2.0

func (c Client) FetchRelationships() ([]*UserRelations, error)

Fetch relationships.

func (*Client) FetchServer

func (c *Client) FetchServer(id string) (*Server, error)

Fetch a server by Id.

func (*Client) FetchUser

func (c *Client) FetchUser(id string) (*User, error)

Fetch an user by Id.

func (*Client) OnChannelCreate

func (c *Client) OnChannelCreate(fn func(channel *Channel))

On channel create event will run when someone creates a channel.

func (*Client) OnChannelDelete

func (c *Client) OnChannelDelete(fn func(channel_id string))

On channel delete event will run when someone deletes a channel.

func (*Client) OnChannelStartTyping

func (c *Client) OnChannelStartTyping(fn func(channel_id, user_id string))

On channel start typing will run when someone starts to type a message.

func (*Client) OnChannelStopTyping

func (c *Client) OnChannelStopTyping(fn func(channel_id, user_id string))

On channel stop typing will run when someone stops the typing status.

func (*Client) OnChannelUpdate

func (c *Client) OnChannelUpdate(fn func(channel_id, clear string, payload map[string]interface{}))

On channel update event will run when someone updates a channel.

func (*Client) OnMessage

func (c *Client) OnMessage(fn func(message *Message))

On message event will run when someone sends a message.

func (*Client) OnMessageDelete

func (c *Client) OnMessageDelete(fn func(channel_id, message_id string))

On message delete event will run when someone deletes a message.

func (*Client) OnMessageUpdate

func (c *Client) OnMessageUpdate(fn func(channel_id, message_id string, payload map[string]interface{}))

On message update event will run when someone updates a message.

func (*Client) OnReady

func (c *Client) OnReady(fn func())

On ready event will run when websocket connection is started and bot is ready to work.

func (*Client) OnServerDelete

func (c *Client) OnServerDelete(fn func(server_id string))

On server delete will run when someone deletes a server.

func (*Client) OnServerMemberJoin added in v0.1.1

func (c *Client) OnServerMemberJoin(fn func(server_id string, user_id string))

On server member join will run when someone joins to the server.

func (*Client) OnServerMemberLeave added in v0.1.1

func (c *Client) OnServerMemberLeave(fn func(server_id string, user_id string))

On server member leave will run when someone left from server.

func (*Client) OnServerMemberUpdate added in v0.1.1

func (c *Client) OnServerMemberUpdate(fn func(server_id, clear string, payload map[string]interface{}))

On server member update will run when a server member updates.

func (*Client) OnServerUpdate

func (c *Client) OnServerUpdate(fn func(server_id, clear string, payload map[string]interface{}))

On server update will run when someone updates a server.

func (*Client) OnUnknownEvent

func (c *Client) OnUnknownEvent(fn func(message string))

On unknown event will run when client gets a unknown event.

func (Client) RemoveFriend added in v0.2.0

func (c Client) RemoveFriend(username string) (*UserRelations, error)

Deny friend request. / Remove friend. User relations struct only will have status. id is not defined for this function.

func (Client) Request

func (c Client) Request(method, path string, data []byte) ([]byte, error)

Send http request

func (*Client) Start

func (c *Client) Start()

type EditChannel

type EditChannel struct {
	Name        string `json:"name,omitempty"`
	Description string `json:"description,omitempty"`
	Icon        string `json:"icon,omitempty"`
	Remove      string `json:"remove,omitempty"`
}

Edit channel struct. Please see: https://developers.revolt.chat/api/#tag/Channel-Information/paths/~1channels~1:channel/patch for more information.

func (*EditChannel) RemoveItem

func (ec *EditChannel) RemoveItem(item string) *EditChannel

Set remove item.

func (*EditChannel) SetDescription

func (ec *EditChannel) SetDescription(desc string) *EditChannel

Set description for struct.

func (*EditChannel) SetIcon

func (ec *EditChannel) SetIcon(autumn_id string) *EditChannel

Set icon for struct.

func (*EditChannel) SetName

func (ec *EditChannel) SetName(name string) *EditChannel

Set name for struct.

type EditMember

type EditMember struct {
	Nickname string   `json:"nickname,omitempty"`
	Avatar   string   `json:"avatar,omitempty"`
	Roles    []string `json:"roles,omitempty"`
	Remove   string   `json:"remove,omitempty"`
}

Edit member struct. Please see https://developers.revolt.chat/api/#tag/Server-Members/paths/~1servers~1:server~1members~1:member/patch for more information.

func (*EditMember) AddRole

func (em *EditMember) AddRole(role_id string) *EditMember

Add role for struct.

func (*EditMember) RemoveItem

func (em *EditMember) RemoveItem(item string) *EditMember

Set remove item.

func (*EditMember) SetAvatar

func (em *EditMember) SetAvatar(autumn_id string) *EditMember

Set avatar for struct.

func (*EditMember) SetNickname

func (em *EditMember) SetNickname(nick string) *EditMember

Set nickname for struct.

type EditRole

type EditRole struct {
	Name   string `json:"name,omitempty"`
	Colour string `json:"colour,omitempty"`
	Hoist  bool   `json:"hoist,omitempty"`
	Rank   int    `json:"rank,omitempty"`
	Remove string `json:"remove,omitempty"`
}

Edit role struct.

func (*EditRole) IsHoist

func (er *EditRole) IsHoist(hoist bool) *EditRole

Set hoist boolean value for struct.

func (*EditRole) RemoveColour

func (er *EditRole) RemoveColour() *EditRole

Set role ranking for struct.

func (*EditRole) SetColour

func (er *EditRole) SetColour(color string) *EditRole

Set valid HTML color for struct.

func (*EditRole) SetName

func (er *EditRole) SetName(name string) *EditRole

Set name for struct.

func (*EditRole) SetRank

func (er *EditRole) SetRank(rank int) *EditRole

Set role ranking for struct.

type EditServer

type EditServer struct {
	Name           string            `json:"name,omitempty"`
	Description    string            `json:"description,omitempty"`
	Icon           string            `json:"icon,omitempty"`
	Banner         string            `json:"banner,omitempty"`
	Categories     []*ServerCategory `json:"categories,omitempty"`
	SystemMessages *SystemMessages   `json:"system_messages,omitempty"`
	Remove         string            `json:"remove,omitempty"`
}

Edit server struct. Please see https://developers.revolt.chat/api/#tag/Server-Information/paths/~1servers~1:server/patch for more detail.

func (*EditServer) AddCategory

func (es *EditServer) AddCategory(category *ServerCategory) *EditServer

Add a new category for struct.

func (*EditServer) RemoveItem

func (es *EditServer) RemoveItem(item string) *EditServer

Set remove item.

func (*EditServer) SetBanner

func (es *EditServer) SetBanner(autumn_id string) *EditServer

Set banner for struct.

func (*EditServer) SetDescription

func (es *EditServer) SetDescription(desc string) *EditServer

Set description for struct.

func (*EditServer) SetIcon

func (es *EditServer) SetIcon(autumn_id string) *EditServer

Set icon for struct.

func (*EditServer) SetName

func (es *EditServer) SetName(name string) *EditServer

Set name for struct

func (*EditServer) SetSystemMessages

func (es *EditServer) SetSystemMessages(sm *SystemMessages) *EditServer

Set system messages for struct.

type EditUser

type EditUser struct {
	Status struct {
		Text     string `json:"text,omitempty"`
		Presence string `json:"presence,omitempty"`
	} `json:"status,omitempty"`
	Profile struct {
		Content    string `json:"content,omitempty"`
		Background string `json:"background,omitempty"`
	} `json:"profile,omitempty"`
	Avatar string `json:"avatar,omitempty"`
	Remove string `json:"remove,omitempty"`
}

Edit client user struct. See https://developers.revolt.chat/api/#tag/User-Information/paths/~1users~1@me/patch for more information.

func (*EditUser) SetAvatar

func (eu *EditUser) SetAvatar(autumn_id string) *EditUser

Set avatar for struct.

func (*EditUser) SetProfile

func (eu *EditUser) SetProfile(content, background string) *EditUser

Set profile informations for struct.

func (*EditUser) SetRemove

func (eu *EditUser) SetRemove(item string) *EditUser

Set remove item for struct.

func (*EditUser) SetStatus

func (eu *EditUser) SetStatus(text, presence string) *EditUser

Set status for struct.

type FetchedBans

type FetchedBans struct {
	Users []*User `json:"users"`
	Bans  []struct {
		Ids struct {
			UserId   string `json:"user"`
			ServerUd string `json:"server"`
		} `json:"_id"`
		Reason string `json:"reason"`
	} `json:"bans"`
}

Fetched bans struct.

type FetchedMembers

type FetchedMembers struct {
	Members []*Member `json:"members"`
	Users   []*User   `json:"users"`
}

Fetched members struct.

type FetchedMessages

type FetchedMessages struct {
	Messages []*Message `json:"messages"`
	Users    []*User    `json:"users"`
}

Fetched messages struct.

type Member

type Member struct {
	Informations struct {
		ServerId string `json:"server"`
		UserId   string `json:"user"`
	} `json:"_id"`
	Nickname string      `json:"nickname"`
	Avatar   *Attachment `json:"avatar"`
	Roles    []string    `json:"roles"`
}

Server member struct.

type Message

type Message struct {
	Client    *Client
	CreatedAt time.Time

	Id          string          `json:"_id"`
	Nonce       string          `json:"nonce"`
	ChannelId   string          `json:"channel"`
	AuthorId    string          `json:"author"`
	Content     interface{}     `json:"content"`
	Edited      interface{}     `json:"edited"`
	Embeds      []*MessageEmbed `json:"embeds"`
	Attachments []*Attachment   `json:"attachments"`
	Mentions    []string        `json:"mentions"`
	Replies     []string        `json:"replies"`
}

Message struct

func (*Message) CalculateCreationDate

func (c *Message) CalculateCreationDate() error

Calculate creation date and edit the struct.

func (Message) Delete

func (m Message) Delete() error

Delete the message.

func (*Message) Edit

func (m *Message) Edit(content string) error

Edit message content.

func (Message) Reply

func (m Message) Reply(mention bool, sm *SendMessage) (*Message, error)

Reply to the message.

type MessageEdited

type MessageEdited struct {
	Date int `json:"$date"`
}

Message edited struct.

type MessageEmbed

type MessageEmbed struct {
	Type        string `json:"type"`
	Url         string `json:"url"`
	Special     *MessageSpecialEmbed
	Title       string                `json:"title"`
	Description string                `json:"description"`
	Image       *MessageEmbeddedImage `json:"image"`
	Video       *MessageEmbeddedVideo `json:"video"`
	IconUrl     string                `json:"icon_url"`
	Color       string                `json:"color"`
}

Message embed struct.

type MessageEmbeddedImage

type MessageEmbeddedImage struct {
	Size   string `json:"size"`
	Url    string `json:"url"`
	Width  int    `json:"width"`
	Height int    `json:"height"`
}

Message embedded image struct

type MessageEmbeddedVideo

type MessageEmbeddedVideo struct {
	Url    string `json:"url"`
	Width  int    `json:"width"`
	Height int    `json:"height"`
}

Message embedded video struct

type MessageSpecialEmbed

type MessageSpecialEmbed struct {
	Type        string `json:"type"`
	Id          string `json:"id"`
	ContentType string `json:"content_type"`
}

Message special embed struct.

type Permissions

type Permissions struct {
	Bitvise     uint
	Mode        string // can ben CHANNEL, SERVER or USER
	Permissions map[string]uint
}

Permissions struct

func (*Permissions) Add

func (p *Permissions) Add(perms ...string) *Permissions

Add new permission(s).

func (Permissions) Calculate

func (p Permissions) Calculate(perms ...string) uint

Calculate perms and return unsigned int.

func (Permissions) Has

func (p Permissions) Has(perm string) bool

Calculate if bitvise has permission

func (*Permissions) InitChannel

func (p *Permissions) InitChannel() *Permissions

Init all of the perms for channel.

func (*Permissions) InitServer

func (p *Permissions) InitServer() *Permissions

Init all of the perms for server.

func (*Permissions) InitUser

func (p *Permissions) InitUser() *Permissions

Init all of the perms for user.

func (*Permissions) Remove

func (p *Permissions) Remove(perms ...string) *Permissions

Remove permission(s).

type SelfBot

type SelfBot struct {
	Email        string `json:"-"`
	Password     string `json:"-"`
	Id           string `json:"id"`
	UserId       string `json:"user_id"`
	SessionToken string `json:"session_token"`
}

Self bot struct.

type SendMessage

type SendMessage struct {
	Content     string   `json:"content,omitempty"`
	Attachments []string `json:"attachments,omitempty"`
	Nonce       string   `json:"nonce,omitempty"`
	DeleteAfter uint     `json:"-"`
	Replies     []struct {
		Id      string `json:"id,omitempty"`
		Mention bool   `json:"mention"`
	} `json:"replies,omitempty"`
}

Similar to message, but created for send message function.

func (*SendMessage) AddAttachment

func (sms *SendMessage) AddAttachment(attachment string) *SendMessage

Add a new attachment.

func (*SendMessage) AddReply

func (sms *SendMessage) AddReply(id string, mention bool) *SendMessage

Add a new reply.

func (*SendMessage) CreateNonce

func (sms *SendMessage) CreateNonce() *SendMessage

Create a unique nonce.

func (*SendMessage) SetContent

func (sms *SendMessage) SetContent(content string) *SendMessage

Set content.

func (*SendMessage) SetContentf

func (sms *SendMessage) SetContentf(format string, values ...interface{}) *SendMessage

Set and format content.

func (*SendMessage) SetDeleteAfter

func (sms *SendMessage) SetDeleteAfter(second uint) *SendMessage

Set delete after option.

type Server

type Server struct {
	Client    *Client
	CreatedAt time.Time

	Id                 string                 `json:"_id"`
	Nonce              string                 `json:"nonce"`
	OwnerId            string                 `json:"owner"`
	Name               string                 `json:"name"`
	Description        string                 `json:"description"`
	ChannelIds         []string               `json:"channels"`
	Categories         []*ServerCategory      `json:"categories"`
	SystemMessages     *SystemMessages        `json:"system_messages"`
	Roles              map[string]interface{} `json:"roles"`
	DefaultPermissions []interface{}          `json:"default_permissions"`
	Icon               *Attachment            `json:"icon"`
	Banner             *Attachment            `json:"banner"`
}

Server struct.

func (Server) BanMember

func (s Server) BanMember(id, reason string) error

Ban a member from server.

func (*Server) CalculateCreationDate

func (s *Server) CalculateCreationDate() error

Calculate creation date and edit the struct.

func (Server) CreateRole

func (s Server) CreateRole(name string) (string, uint, uint, error)

Create a new role for server. Returns string (role id), uint (server perms), uint (channel perms) and error.

func (Server) CreateTextChannel

func (s Server) CreateTextChannel(name, description string) (*Channel, error)

Create a new text-channel.

func (Server) CreateVoiceChannel

func (s Server) CreateVoiceChannel(name, description string) (*Channel, error)

Create a new voice-channel.

func (Server) Delete

func (s Server) Delete() error

Delete / leave server. If the server not created by client, it will leave. Otherwise it will be deleted.

func (Server) DeleteRole

func (s Server) DeleteRole(id string) error

Delete a server role.

func (Server) Edit

func (s Server) Edit(es *EditServer) error

Edit server.

func (Server) EditMember

func (s Server) EditMember(id string, em *EditMember) error

Edit a member.

func (Server) EditRole

func (s Server) EditRole(id string, er *EditRole) error

Edit a server role.

func (Server) FetchBans

func (s Server) FetchBans() (*FetchedBans, error)

Fetch server bans.

func (Server) FetchMember

func (s Server) FetchMember(id string) (*Member, error)

Fetch a member from Server.

func (Server) FetchMembers

func (s Server) FetchMembers() (*FetchedMembers, error)

Fetch all of the members from Server.

func (Server) KickMember

func (s Server) KickMember(id string) error

Kick a member from server.

func (Server) SetPermissions

func (s Server) SetPermissions(role_id string, channel_permissions, server_permissions uint) error

Set server permissions for a role. Leave role field empty if you want to edit default permissions

func (Server) UnbanMember

func (s Server) UnbanMember(id string) error

Unban a member from server.

type ServerCategory

type ServerCategory struct {
	Id         string   `json:"id"`
	Title      string   `json:"title"`
	ChannelIds []string `json:"channels"`
}

Server categories struct.

type SystemMessages

type SystemMessages struct {
	UserJoined string `json:"user_joined,omitempty"`
	UserLeft   string `json:"user_left,omitempty"`
	UserKicked string `json:"user_kicker,omitempty"`
	UserBanned string `json:"user_banned,omitempty"`
}

System messages struct.

type User

type User struct {
	Client    *Client
	CreatedAt time.Time

	Id             string           `json:"_id"`
	Username       string           `json:"username"`
	Avatar         *Attachment      `json:"avatar"`
	Relations      []*UserRelations `json:"relations"`
	Badges         int              `json:"badges"`
	Status         *UserStatus      `json:"status"`
	Relationship   string           `json:"relationship"`
	IsOnline       bool             `json:"online"`
	Flags          int              `json:"flags"`
	BotInformation *BotInformation  `json:"bot"`
}

User struct.

func (User) Block added in v0.2.0

func (u User) Block() (*UserRelations, error)

Block user.

func (*User) CalculateCreationDate

func (u *User) CalculateCreationDate() error

Calculate creation date and edit the struct.

func (User) CreateDirectMessage

func (u User) CreateDirectMessage() (*Channel, error)

Create a DM with the user.

func (User) FetchDefaultAvatar added in v0.1.1

func (u User) FetchDefaultAvatar() (*Binary, error)

Fetch default user avatar.

func (User) FetchRelationship added in v0.2.0

func (u User) FetchRelationship() (*UserRelations, error)

Fetch user relationship.

func (User) FormatMention

func (u User) FormatMention() string

Create a mention format.

func (User) Unblock added in v0.2.0

func (u User) Unblock() (*UserRelations, error)

Un-block user.

type UserRelations

type UserRelations struct {
	Id     string `json:"_id"`
	Status string `json:"status"`
}

User relations struct.

type UserStatus

type UserStatus struct {
	Text     string `json:"text"`
	Presence string `json:"presence"`
}

User status struct.

Jump to

Keyboard shortcuts

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