module

package
v0.0.0-...-27d56bb Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2026 License: MPL-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SetLogger

func SetLogger(logger hclog.Logger)

SetLogger allows modules to set a logger for the discord module package. This enables error logging before the module terminates.

Types

type GRPCServer

type GRPCServer struct {
	proto.UnimplementedHookServer
	Impl shared.Hook // Hook functions to be called from runtime (module developers must implement this!)
	// contains filtered or unexported fields
}

`module/server.go` implements the gRPC server for receiving from the runtime.

This part works on the module-side and is the gRPC server implementation for the runtime.

func (*GRPCServer) OnCreateInteraction

func (m *GRPCServer) OnCreateInteraction(ctx context.Context, req *proto.Interaction) (resp *proto_common.Empty, err error)

OnCreateInteraction is called when an interaction is created from the runtime.

func (*GRPCServer) OnCreateMessage

func (m *GRPCServer) OnCreateMessage(ctx context.Context, req *proto.Message) (resp *proto_common.Empty, err error)

OnCreateChatMessage is called when a message is created from the runtime.

func (*GRPCServer) OnEvent

func (m *GRPCServer) OnEvent(ctx context.Context, req *proto.OnEventRequest) (resp *proto_common.Empty, err error)

OnEvent is called when an (discord) event is created from the runtime.

func (*GRPCServer) OnInit

func (m *GRPCServer) OnInit(ctx context.Context, req *proto.InitRequest) (resp *proto.InitResponse, err error)

OnInit is called when the discord plugin is initialized.

type HelperClientImpl

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

HelperClientImpl implements the Helper interface for module-side operations. This client communicates with the runtime server to perform Discord operations.

func (*HelperClientImpl) ApplicationCommandCreate

func (h *HelperClientImpl) ApplicationCommandCreate(appID string, guildID string, cmd *discordgo.ApplicationCommand) (*discordgo.ApplicationCommand, error)

ApplicationCommandCreate creates a new application command.

func (*HelperClientImpl) ApplicationCommandDelete

func (h *HelperClientImpl) ApplicationCommandDelete(appID, guildID, cmdID string) error

ApplicationCommandDelete deletes an application command.

func (*HelperClientImpl) ApplicationCommandEdit

func (h *HelperClientImpl) ApplicationCommandEdit(appID, guildID, cmdID string, cmd *discordgo.ApplicationCommand) (*discordgo.ApplicationCommand, error)

ApplicationCommandEdit edits an existing application command.

func (*HelperClientImpl) ApplicationCommands

func (h *HelperClientImpl) ApplicationCommands(appID, guildID string) ([]*discordgo.ApplicationCommand, error)

ApplicationCommands retrieves all application commands.

func (*HelperClientImpl) Channel

func (h *HelperClientImpl) Channel(channelID string) (*discordgo.Channel, error)

Channel retrieves information about a channel.

func (*HelperClientImpl) ChannelDelete

func (h *HelperClientImpl) ChannelDelete(channelID string) (*discordgo.Channel, error)

ChannelDelete deletes a channel.

func (*HelperClientImpl) ChannelEdit

func (h *HelperClientImpl) ChannelEdit(channelID string, data *discordgo.ChannelEdit) (*discordgo.Channel, error)

ChannelEdit modifies a channel's properties.

func (*HelperClientImpl) ChannelMessage

func (h *HelperClientImpl) ChannelMessage(channelID, messageID string) (*discordgo.Message, error)

ChannelMessage retrieves a single message from a channel.

func (*HelperClientImpl) ChannelMessageDelete

func (h *HelperClientImpl) ChannelMessageDelete(channelID, messageID string) error

ChannelMessageDelete deletes a message from a channel.

func (*HelperClientImpl) ChannelMessageEdit

func (h *HelperClientImpl) ChannelMessageEdit(channelID, messageID, content string) (*discordgo.Message, error)

ChannelMessageEdit edits a message with simple text content.

func (*HelperClientImpl) ChannelMessageEditComplex

func (h *HelperClientImpl) ChannelMessageEditComplex(m *discordgo.MessageEdit) (*discordgo.Message, error)

ChannelMessageEditComplex edits a message with complex data.

func (*HelperClientImpl) ChannelMessageSend

func (h *HelperClientImpl) ChannelMessageSend(channelID string, content string) (*discordgo.Message, error)

ChannelMessageSend sends a simple text message to a channel.

func (*HelperClientImpl) ChannelMessageSendComplex

func (h *HelperClientImpl) ChannelMessageSendComplex(channelID string, data *discordgo.MessageSend) (*discordgo.Message, error)

ChannelMessageSendComplex sends a complex message with attachments, embeds, etc.

func (*HelperClientImpl) ChannelMessageSendEmbed

func (h *HelperClientImpl) ChannelMessageSendEmbed(channelID string, embed *discordgo.MessageEmbed) (*discordgo.Message, error)

ChannelMessageSendEmbed sends a message with a single embed.

func (*HelperClientImpl) ChannelMessageSendEmbeds

func (h *HelperClientImpl) ChannelMessageSendEmbeds(channelID string, embeds []*discordgo.MessageEmbed) (*discordgo.Message, error)

ChannelMessageSendEmbeds sends a message with multiple embeds.

func (*HelperClientImpl) ChannelMessages

func (h *HelperClientImpl) ChannelMessages(channelID string, limit int, beforeID, afterID, aroundID string) ([]*discordgo.Message, error)

ChannelMessages retrieves multiple messages from a channel.

func (*HelperClientImpl) ChannelTyping

func (h *HelperClientImpl) ChannelTyping(channelID string) error

ChannelTyping triggers typing indicator in a channel.

func (*HelperClientImpl) Gateway

func (h *HelperClientImpl) Gateway() (string, error)

Gateway retrieves gateway URL.

func (*HelperClientImpl) GatewayBot

func (h *HelperClientImpl) GatewayBot() (*discordgo.GatewayBotResponse, error)

GatewayBot retrieves gateway bot information.

func (*HelperClientImpl) Guild

func (h *HelperClientImpl) Guild(guildID string) (*discordgo.Guild, error)

Guild retrieves information about a guild.

func (*HelperClientImpl) GuildChannels

func (h *HelperClientImpl) GuildChannels(guildID string) ([]*discordgo.Channel, error)

GuildChannels retrieves all channels in a guild.

func (*HelperClientImpl) GuildMember

func (h *HelperClientImpl) GuildMember(guildID, userID string) (*discordgo.Member, error)

GuildMember retrieves a specific guild member.

func (*HelperClientImpl) GuildMembers

func (h *HelperClientImpl) GuildMembers(guildID string, after string, limit int) ([]*discordgo.Member, error)

GuildMembers retrieves guild members.

func (*HelperClientImpl) GuildRoles

func (h *HelperClientImpl) GuildRoles(guildID string) ([]*discordgo.Role, error)

GuildRoles retrieves all roles in a guild.

func (*HelperClientImpl) InteractionRespond

func (h *HelperClientImpl) InteractionRespond(interaction *discordgo.Interaction, resp *discordgo.InteractionResponse) error

InteractionRespond responds to an interaction.

func (*HelperClientImpl) InteractionResponseEdit

func (h *HelperClientImpl) InteractionResponseEdit(interaction *discordgo.Interaction, newresp *discordgo.WebhookEdit) (*discordgo.Message, error)

InteractionResponseEdit edits an interaction response.

func (*HelperClientImpl) MessageReactionAdd

func (h *HelperClientImpl) MessageReactionAdd(channelID, messageID, emojiID string) error

MessageReactionAdd adds a reaction to a message.

func (*HelperClientImpl) MessageReactionRemove

func (h *HelperClientImpl) MessageReactionRemove(channelID, messageID, emojiID, userID string) error

MessageReactionRemove removes a reaction from a message.

func (*HelperClientImpl) MessageReactionsRemoveAll

func (h *HelperClientImpl) MessageReactionsRemoveAll(channelID, messageID string) error

MessageReactionsRemoveAll removes all reactions from a message.

func (*HelperClientImpl) ThreadJoin

func (h *HelperClientImpl) ThreadJoin(threadID string) error

ThreadJoin joins a thread.

func (*HelperClientImpl) ThreadLeave

func (h *HelperClientImpl) ThreadLeave(threadID string) error

ThreadLeave leaves a thread.

func (*HelperClientImpl) ThreadMemberAdd

func (h *HelperClientImpl) ThreadMemberAdd(threadID, memberID string) error

ThreadMemberAdd adds a member to a thread.

func (*HelperClientImpl) ThreadMemberRemove

func (h *HelperClientImpl) ThreadMemberRemove(threadID, memberID string) error

ThreadMemberRemove removes a member from a thread.

func (*HelperClientImpl) ThreadStart

func (h *HelperClientImpl) ThreadStart(channelID, name string, typ discordgo.ChannelType, archiveDuration int) (*discordgo.Channel, error)

ThreadStart creates a new thread.

func (*HelperClientImpl) User

func (h *HelperClientImpl) User(userID string) (*discordgo.User, error)

User retrieves information about a user.

func (*HelperClientImpl) UserChannelCreate

func (h *HelperClientImpl) UserChannelCreate(recipientID string) (*discordgo.Channel, error)

UserChannelCreate creates a DM channel with a user.

func (*HelperClientImpl) UserChannelPermissions

func (h *HelperClientImpl) UserChannelPermissions(userID, channelID string) (int64, error)

UserChannelPermissions retrieves user permissions for a channel.

func (*HelperClientImpl) VoiceRegions

func (h *HelperClientImpl) VoiceRegions() ([]*discordgo.VoiceRegion, error)

VoiceRegions retrieves available voice regions.

func (*HelperClientImpl) WebhookCreate

func (h *HelperClientImpl) WebhookCreate(channelID, name, avatar string) (*discordgo.Webhook, error)

WebhookCreate creates a new webhook.

func (*HelperClientImpl) WebhookExecute

func (h *HelperClientImpl) WebhookExecute(webhookID, token string, wait bool, data *discordgo.WebhookParams) (*discordgo.Message, error)

WebhookExecute executes a webhook.

type HookClient

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

HookClient implements the Hook interface for calling runtime's hook functions from module

func (*HookClient) OnCreateChatMessage

func (h *HookClient) OnCreateChatMessage(message *discordgo.Message) error

OnCreateChatMessage calls the runtime's OnCreateChatMessage hook function

func (*HookClient) OnCreateInteraction

func (h *HookClient) OnCreateInteraction(interaction *discordgo.Interaction) error

OnCreateInteraction calls the runtime's OnCreateInteraction hook function

func (*HookClient) OnEvent

func (h *HookClient) OnEvent(eventType string) error

OnEvent calls the runtime's OnEvent hook function

func (*HookClient) OnInit

func (h *HookClient) OnInit(helper shared.Helper) shared.InitResponse

OnInit calls the runtime's OnInit hook function

type ModuleClients

type ModuleClients struct {
	Helper      shared.Helper
	Hook        shared.Hook
	VoiceStream proto.VoiceStreamClient
}

ModuleClients wraps both Helper and Hook clients

func (*ModuleClients) GetVoiceStream

func (m *ModuleClients) GetVoiceStream() proto.VoiceStreamClient

GetVoiceStream returns the VoiceStream client

type Plugin

type Plugin struct {
	plugin.NetRPCUnsupportedPlugin

	Impl   shared.Hook   // Hook implementation (module side)
	Helper shared.Helper // Helper service (provided by runtime, but can be nil)
}

FlexModule uses hashicorp/go-plugin: So we need to declare a separate Plugin for the runtime and module.

`module/server.go` implements the gRPC server for receiving from the runtime.

`module/client.go` implements the gRPC client for making calls to the runtime.

func (*Plugin) GRPCClient

func (p *Plugin) GRPCClient(ctx context.Context, broker *plugin.GRPCBroker, c *grpc.ClientConn) (interface{}, error)

func (*Plugin) GRPCServer

func (p *Plugin) GRPCServer(broker *plugin.GRPCBroker, s *grpc.Server) error

type VoiceClient

type VoiceClient struct {

	// Public channels for module usage
	SendChan chan *VoiceSendRequest
	RecvChan chan *VoicePacket
	// contains filtered or unexported fields
}

VoiceClient provides a client interface for voice streaming

func NewVoiceClient

func NewVoiceClient(client pb.VoiceStreamClient, moduleID string) *VoiceClient

NewVoiceClient creates a new voice client

func (*VoiceClient) GetStats

func (vc *VoiceClient) GetStats() (packetsSent, packetsRecv, bytesSent, bytesRecv uint64)

GetStats returns client statistics

func (*VoiceClient) Join

func (vc *VoiceClient) Join(ctx context.Context, guildID, channelID string, mute, deaf bool) error

Join joins a voice channel

func (*VoiceClient) Leave

func (vc *VoiceClient) Leave() error

Leave leaves the voice channel

func (*VoiceClient) Send

func (vc *VoiceClient) Send(opusData []byte, priority int32, timeoutMs int64)

Send is a convenience method to send opus data

func (*VoiceClient) SendWithDefaults

func (vc *VoiceClient) SendWithDefaults(opusData []byte)

SendWithDefaults sends opus data with default settings (priority=0, timeout=5s)

func (*VoiceClient) Speaking

func (vc *VoiceClient) Speaking(speaking bool) error

Speaking sets the speaking state

func (*VoiceClient) WaitForReady

func (vc *VoiceClient) WaitForReady(timeout time.Duration) error

WaitForReady waits until send/receive channels are ready (useful for testing)

type VoicePacket

type VoicePacket struct {
	OpusData  []byte
	SSRC      uint32
	Sequence  uint32
	Timestamp uint32
}

VoicePacket represents a received voice packet

type VoiceSendRequest

type VoiceSendRequest struct {
	OpusData  []byte
	Priority  int32
	TimeoutMs int64
}

VoiceSendRequest represents a voice packet to send

Jump to

Keyboard shortcuts

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