client

package
v0.2.5 Latest Latest
Warning

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

Go to latest
Published: May 8, 2023 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DiscordApiURL = "https://discord.com/api"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type BotClient

type BotClient struct {
	Token  string
	Client *http.Client
}

func NewBot

func NewBot(token string) *BotClient

func (*BotClient) GetChannelClient added in v0.2.1

func (botClient *BotClient) GetChannelClient(channelId discord.Snowflake) *ChannelClient

func (*BotClient) GetGuildClient

func (botClient *BotClient) GetGuildClient(guildId discord.Snowflake) *GuildClient

func (*BotClient) GetSelfUserClient added in v0.2.1

func (botClient *BotClient) GetSelfUserClient() *UserClient

func (*BotClient) GetUserClient added in v0.2.1

func (botClient *BotClient) GetUserClient(userId discord.Snowflake) *UserClient

func (*BotClient) MakeRequest

func (botClient *BotClient) MakeRequest(discordRequest DiscordRequest) (response *http.Response, err error)

type ChannelClient added in v0.2.1

type ChannelClient struct {
	ChannelId discord.Snowflake
	Bot       *BotClient
}

func (*ChannelClient) MakeRequest added in v0.2.1

func (channelClient *ChannelClient) MakeRequest(discordRequest DiscordRequest) (response *http.Response, err error)

func (*ChannelClient) SendMessage added in v0.2.1

func (channelClient *ChannelClient) SendMessage(messageData SendMessageData) (*discord.Message, error)

type DiscordRequest

type DiscordRequest struct {
	ExpectedStatus int
	Method         string
	Endpoint       string
	Body           []byte

	UnmarshalTo interface{}

	DisableAuth        bool
	DisableStatusCheck bool
	AdditionalHeaders  map[string]string
}

func (*DiscordRequest) GetUrl

func (discordRequest *DiscordRequest) GetUrl() string

func (*DiscordRequest) ValidateEndpoint

func (discordRequest *DiscordRequest) ValidateEndpoint()

type GuildClient

type GuildClient struct {
	GuildId discord.Snowflake
	Bot     *BotClient
}

func (*GuildClient) FetchGuild added in v0.2.5

func (guildClient *GuildClient) FetchGuild() (*discord.Guild, error)

func (*GuildClient) GetMemberClient

func (guildClient *GuildClient) GetMemberClient(memberId discord.Snowflake) *MemberClient

func (*GuildClient) MakeRequest

func (guildClient *GuildClient) MakeRequest(discordRequest DiscordRequest) (response *http.Response, err error)

type MemberClient

type MemberClient struct {
	MemberId    discord.Snowflake
	GuildClient *GuildClient
}

func (*MemberClient) AddRoleToMember

func (memberClient *MemberClient) AddRoleToMember(opts ModifyMemberRoleOpts) error

func (*MemberClient) FetchMember

func (memberClient *MemberClient) FetchMember() (*discord.Member, error)

func (*MemberClient) MakeRequest

func (memberClient *MemberClient) MakeRequest(discordRequest DiscordRequest) (response *http.Response, err error)

type ModifyMemberRoleOpts

type ModifyMemberRoleOpts struct {
	RoleID discord.Snowflake

	Reason string
}

type SendMessageData added in v0.2.1

type SendMessageData struct {
	Content         *string                  `json:"content,omitempty"`
	TTS             *bool                    `json:"tts,omitempty"`
	Embeds          []discord.Embed          `json:"embeds,omitempty"`
	AllowedMentions *discord.AllowedMentions `json:"allowed_mentions,omitempty"`
	// Channel ID optional
	MessageReference *discord.MessageReference     `json:"message_reference,omitempty"`
	Components       []components.MessageComponent `json:"components,omitempty"`
	StickerIds       []discord.Snowflake           `json:"sticker_ids,omitempty"`
	Attachments      []discord.Attachment          `json:"attachments,omitempty"`
	// Only supports "SUPPRESS_EMBEDS" (1<<2) and "SUPPRESS_NOTIFICATIONS" (1<<12)
	Flags *int `json:"flags,omitempty"`
}

type UserClient added in v0.2.1

type UserClient struct {
	UserId discord.Snowflake
	Bot    *BotClient
}

func (*UserClient) CreateDMChannel added in v0.2.1

func (userClient *UserClient) CreateDMChannel() (*discord.Channel, error)

func (*UserClient) GetIdAsString added in v0.2.1

func (userClient *UserClient) GetIdAsString() string

func (*UserClient) MakeRequest added in v0.2.1

func (userClient *UserClient) MakeRequest(discordRequest DiscordRequest) (response *http.Response, err error)

func (*UserClient) SendMessage added in v0.2.1

func (userClient *UserClient) SendMessage(messageData SendMessageData) (*discord.Message, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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