common

package
v0.0.30 Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2025 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetRoleNames added in v0.0.22

func GetRoleNames(member *discordgo.Member, session *discordgo.Session, guildID string) []string

GetRoleNames returns the plain-english names of the roles a member has.

func HasPermission

func HasPermission(member *discordgo.Member, session *discordgo.Session, guildID string, config *RoleConfig, cmdData *discordgo.ApplicationCommandInteractionData) bool

HasPermission checks if a member has permission to execute a command.

func NoPermissionError

func NoPermissionError(command string) error

NoPermissionError returns a formatted error message for permission denied.

Types

type AutocompleteHandler added in v0.0.27

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

AutocompleteHandler handles network autocomplete for Discord commands.

func NewAutocompleteHandler added in v0.0.27

func NewAutocompleteHandler(bot BotContext, log *logrus.Logger) *AutocompleteHandler

NewAutocompleteHandler creates a new autocomplete handler.

func (*AutocompleteHandler) HandleNetworkAutocomplete added in v0.0.27

func (h *AutocompleteHandler) HandleNetworkAutocomplete(s *discordgo.Session, i *discordgo.InteractionCreate, commandName string)

HandleNetworkAutocomplete handles autocomplete for network selection. It returns active networks first (alphabetically sorted), followed by inactive networks.

type BotContext

type BotContext interface {
	// GetSession returns the Discord session.
	GetSession() *discordgo.Session
	// GetScheduler returns the scheduler.
	GetScheduler() *scheduler.Scheduler
	// GetMonitorRepo returns the monitor repository.
	GetMonitorRepo() *store.MonitorRepo
	// GetChecksRepo returns the checks repository.
	GetChecksRepo() *store.ChecksRepo
	// GetMentionsRepo returns the mentions repository.
	GetMentionsRepo() *store.MentionsRepo
	// GetHiveSummaryRepo returns the Hive summary repository.
	GetHiveSummaryRepo() *store.HiveSummaryRepo
	// GetGrafana returns the Grafana client.
	GetGrafana() grafana.Client
	// GetHive returns the Hive client.
	GetHive() hive.Hive
	// GetCartographoor returns the cartographoor service.
	GetCartographoor() *cartographoor.Service
	// GetRoleConfig returns the role configuration.
	GetRoleConfig() *RoleConfig
}

BotContext provides access to bot functionality needed by commands.

type Command

type Command interface {
	// Name returns the name of the command.
	Name() string
	// Register registers the command with the given session.
	Register(*discordgo.Session) error
	// Handle handles the command.
	Handle(*discordgo.Session, *discordgo.InteractionCreate)
}

Command represents a Discord slash command.

type RoleConfig

type RoleConfig struct {
	AdminRoles  map[string]bool   // Map of admin role names that have full access
	ClientRoles map[string]string // Map of client names to their team role names
}

RoleConfig defines the roles required for each permission level.

Jump to

Keyboard shortcuts

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