client

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2023 License: GPL-3.0 Imports: 12 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 ActiveThreadsResponse added in v0.3.2

type ActiveThreadsResponse struct {
	Threads       []discord.Channel      `json:"threads"`
	ThreadMembers []discord.ThreadMember `json:"members"`
}

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) GetSelfUserID added in v0.3.8

func (botClient *BotClient) GetSelfUserID() discord.Snowflake

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) AddThreadMember added in v0.3.5

func (channelClient *ChannelClient) AddThreadMember(userId discord.Snowflake) error

func (*ChannelClient) CreateThread added in v0.3.2

func (channelClient *ChannelClient) CreateThread(threadData CreateThreadData) (*discord.Channel, error)

func (*ChannelClient) Edit added in v0.3.2

func (channelClient *ChannelClient) Edit(data ModifyChannelData) (*discord.Channel, error)

func (*ChannelClient) EditMessage added in v0.4.2

func (channelClient *ChannelClient) EditMessage(messageId discord.Snowflake, editData discord.ResponseEditData) (*discord.Message, error)

func (*ChannelClient) FetchChannel added in v0.3.4

func (channelClient *ChannelClient) FetchChannel() (*discord.Channel, error)

func (*ChannelClient) GetThreadMember added in v0.3.5

func (channelClient *ChannelClient) GetThreadMember(request GetThreadMemberRequest) (*discord.ThreadMember, error)

func (*ChannelClient) JoinThread added in v0.3.5

func (channelClient *ChannelClient) JoinThread() error

func (*ChannelClient) LeaveThread added in v0.3.5

func (channelClient *ChannelClient) LeaveThread() error

func (*ChannelClient) ListThreadMembers added in v0.3.5

func (channelClient *ChannelClient) ListThreadMembers(request ListThreadMemberRequest) ([]discord.ThreadMember, error)

func (*ChannelClient) MakeRequest added in v0.2.1

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

func (*ChannelClient) RemoveThreadMember added in v0.3.5

func (channelClient *ChannelClient) RemoveThreadMember(userId discord.Snowflake) error

func (*ChannelClient) SendMessage added in v0.2.1

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

type CreateThreadData added in v0.3.2

type CreateThreadData struct {
	Name string `json:"name"`

	// Seconds
	AutoArchiveDuration *int `json:"auto_archive_duration,omitempty"`

	//  Valid types: AnnouncementThread, PublicThread, PrivateThread
	Type channel_type.ChannelType `json:"type"`

	// Whether non-mods can invite (only if private thread)
	Invitable *bool `json:"invitable,omitempty"`

	// Seconds
	RateLimit *int `json:"rate_limit_per_user,omitempty"`

	Reason *string `json:"-"` // Audit log reason, optional
}

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 GetThreadMemberRequest added in v0.3.5

type GetThreadMemberRequest struct {
	UserId discord.Snowflake
	// Whether to request a "member" object in the ThreadMember response, requires GUILD_MEMBERS
	WithMember bool
}

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) GetActiveThreads added in v0.3.2

func (guildClient *GuildClient) GetActiveThreads() (ActiveThreadsResponse, error)

func (*GuildClient) GetChannels added in v0.3.9

func (guildClient *GuildClient) GetChannels() ([]discord.Channel, 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 ListThreadMemberRequest added in v0.3.5

type ListThreadMemberRequest struct {
	// Whether to request a "member" object in the ThreadMember response, requires GUILD_MEMBERS privileged intent
	WithMember bool
	// The last member fetched
	After *discord.Snowflake
	// Max members to fetch in one request
	Limit *int
}

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 ModifyChannelData added in v0.3.2

type ModifyChannelData interface {
	ToJson() ([]byte, error)
	GetReason() *string
}

type ModifyGroupDMChannelData added in v0.3.2

type ModifyGroupDMChannelData struct {
	Name      *string `json:"name,omitempty"`
	IconBytes []byte  `json:"-"`
	Icon      *string `json:"icon,omitempty"`

	Reason *string `json:"-"` // Audit log reason, optional
}

func (ModifyGroupDMChannelData) GetReason added in v0.3.2

func (modifyData ModifyGroupDMChannelData) GetReason() *string

func (ModifyGroupDMChannelData) ToJson added in v0.3.2

func (modifyData ModifyGroupDMChannelData) ToJson() ([]byte, error)

type ModifyGuildChannelData added in v0.3.2

type ModifyGuildChannelData struct {
	Name *string `json:"name,omitempty"`
	// Can only switch between text and announcement channels
	Type     *channel_type.ChannelType `json:"type,omitempty"`
	Position *int                      `json:"position,omitempty"`
	Topic    *string                   `json:"topic,omitempty"`
	NSFW     *bool                     `json:"nsfw,omitempty"`
	// Slow-mode (in seconds)
	RateLimit *int `json:"rate_limit_per_user,omitempty"`

	// Voice Channels Only:
	Bitrate          *int    `json:"bitrate,omitempty"`
	UserLimit        *int    `json:"user_limit,omitempty"`
	RtcRegion        *string `json:"rtc_region,omitempty"`
	VideoQualityMode *int    `json:"video_quality_mode,omitempty"`

	// Default archive duration for user-created threads (in minutes), supports: 60, 1440, 4320, 10080
	DefaultAutoArchiveDuration *int `json:"default_auto_archive_duration,omitempty"`
	// Slow-mode (in seconds)
	DefaultThreadRateLimit *int                `json:"default_thread_rate_limit_per_user,omitempty"`
	PermissionOverwrites   []discord.Overwrite `json:"permission_overwrites,omitempty"`
	// Category ID
	ParentId *discord.Snowflake `json:"parent_id,omitempty"`

	// Forums Only:
	// Only supports REQUIRE_TAG (1<<4)
	Flags                *int                     `json:"flags,omitempty"`
	AvailableTags        []discord.Tag            `json:"available_tags,omitempty"`
	DefaultReactionEmoji *discord.DefaultReaction `json:"default_reaction_emoji,omitempty"`
	DefaultSortOrder     *int                     `json:"default_sort_order,omitempty"`
	DefaultForumLayout   *int                     `json:"default_forum_layout,omitempty"`

	Reason *string `json:"-"` // Audit log reason, optional
}

func (ModifyGuildChannelData) GetReason added in v0.3.2

func (modifyData ModifyGuildChannelData) GetReason() *string

func (ModifyGuildChannelData) ToJson added in v0.3.2

func (modifyData ModifyGuildChannelData) ToJson() ([]byte, error)

type ModifyMemberRoleOpts

type ModifyMemberRoleOpts struct {
	RoleID discord.Snowflake

	Reason string
}

type ModifyThreadData added in v0.3.2

type ModifyThreadData struct {
	Name     *string `json:"name,omitempty"`
	Archived *bool   `json:"archived,omitempty"`
	// Minutes, only supports: 60, 1440, 4320, 10080
	AutoArchiveDuration *int  `json:"auto_archive_duration,omitempty"`
	Locked              *bool `json:"locked,omitempty"`
	Invitable           *bool `json:"invitable,omitempty"`
	// Slow-mode (in seconds)
	RateLimit *int `json:"rate_limit_per_user,omitempty"`

	Flags       *int          `json:"flags,omitempty"`
	AppliedTags []discord.Tag `json:"applied_tags,omitempty"`

	Reason *string `json:"-"` // Audit log reason, optional
}

func (ModifyThreadData) GetReason added in v0.3.2

func (modifyData ModifyThreadData) GetReason() *string

func (ModifyThreadData) ToJson added in v0.3.2

func (modifyData ModifyThreadData) ToJson() ([]byte, error)

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       []discord.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 ThreadType added in v0.3.2

type ThreadType uint8

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