gophelper

package
v0.0.0-...-ec0d61c Latest Latest
Warning

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

Go to latest
Published: Feb 14, 2021 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	//CATEGORY_MISC Miscellaneous commands
	CATEGORY_MISC = &Category{
		Name:          "Miscellaneous",
		Aliases:       []string{"misc", "miscellaneous"},
		Description:   "Other stuff",
		ReactionEmoji: "✨",
	}

	//CATEGORY_CONFIG Bot config commands
	CATEGORY_CONFIG = &Category{
		Name:          "Bot config",
		Aliases:       []string{"config", "botconfig", "bot_config"},
		Description:   "Bot config related commands",
		ReactionEmoji: "⚙️",
	}

	//CATEGORY_FUN Fun commands
	CATEGORY_FUN = &Category{
		Name:          "Fun",
		Aliases:       []string{"fun"},
		Description:   "Haha funni",
		ReactionEmoji: "😀",
	}

	//CATEGORY_MOD Moderation commands
	CATEGORY_MOD = &Category{
		Name:          "Moderation",
		Aliases:       []string{"moderation", "mod"},
		Description:   "Gang gang",
		ReactionEmoji: "🛡️",
	}

	//CATEGORY_GAMES Game commands
	CATEGORY_GAMES = &Category{
		Name:          "Games",
		Aliases:       []string{"games"},
		Description:   "Simple games vs bot",
		ReactionEmoji: "🎮",
	}
)

Functions

This section is empty.

Types

type Category

type Category struct {
	Name          string
	Aliases       []string
	Description   string
	ReactionEmoji string
}

Category command category

type CategoryConfig

type CategoryConfig struct {
	Description string `json:"description"`
}

CategoryConfig contains structure that categories used for their translation

type Command

type Command struct {
	ID string

	Name string

	Category *Category

	Aliases       []string
	CaseSensitive bool

	NeededPermissions int64

	NSFWOnly bool

	Description  string
	Usage        string
	UsageOnError bool

	RateLimit struct {
		Limit    int
		Duration time.Duration
	}

	LanguageSettings CommandConfig

	Handler func(*CommandContext)
}

Command basic structure of a command

type CommandConfig

type CommandConfig struct {
	Description string `json:"description,omitempty"`
	HelpCommand
	GiveCommand
	EightBallCommand
	PingPongCommand
	StatsCommand
}

CommandConfig contains structure that commands used for their translation

type CommandContext

type CommandContext struct {
	Session *discordgo.Session
	Router  *Router

	Command   *Command
	Arguments []string

	Event *discordgo.MessageCreate
}

CommandContext contains necessary information about command and from where it comes from

type Config

type Config struct {
	Prefix struct {
		Value         []string `json:"prefixes"`
		CaseSensitive bool     `json:"caseSensitive"`
	} `json:"prefix"`

	Language LanguageConfig `json:"language,omitempty"`
}

Config main router config structure

func LoadConfig

func LoadConfig(configPath string, languageConfigPath string) *Config

LoadConfig loads config from file

func (*Config) LoadLanguage

func (config *Config) LoadLanguage(languageConfigPath string) error

LoadLanguage loads language from file to Config object

type EightBallCommand

type EightBallCommand struct {
	NoArgumentsMessage string   `json:"noArgumensMessage,omitempty"`
	Answers            []string `json:"answers,omitempty"`
}

EightBallCommand structure for 8ball command

type GiveCommand

type GiveCommand struct {
	Response struct {
		Mention    string `json:"mention"`
		NonMention string `json:"nonMention"`
	} `json:"response,omitempty"`
}

GiveCommand structure for kitty,doggy etc commands

type HelpCommand

type HelpCommand struct {
	Embed struct {
		Main struct {
			Title       string `json:"title"`
			Description string `json:"description"`
		} `json:"main"`

		CategoryTitle string `json:"categoryTitle"`

		Name   string `json:"name"`
		NoName string `json:"noName"`

		Description   string `json:"description"`
		NoDescription string `json:"noDescription"`

		Usage string `json:"usage"`

		Aliases   string `json:"aliases"`
		NoAliases string `json:"noAliases"`
	} `json:"embed,omitempty"`

	Page string `json:"page,omitempty"`

	CommandNotFound struct {
		Title   string `json:"title"`
		Message string `json:"message"`
	} `json:"commandNotFound,omitempty"`
}

HelpCommand structure for help command

type LanguageConfig

type LanguageConfig struct {
	Errors struct {
		MessageSend       string `json:"messageSend"`
		TooFewPermissions string `json:"tooFewPermissions"`
		NSFWOnly          string `json:"nsfwOnly"`
		RateLimit         string `json:"rateLimit"`
	} `json:"errors"`

	FunFacts   []string                  `json:"funFacts"`
	Commands   map[string]CommandConfig  `json:"commands"`
	Categories map[string]CategoryConfig `json:"categories"`
}

LanguageConfig contains config information that is mainly about translation

type Middleware

type Middleware func(*CommandContext) (bool, func(*CommandContext))

Middleware handler used before running command

type PingPongCommand

type PingPongCommand struct {
	TooManyMatchesMessage string `json:"tooManyMatches,omitempty"`

	Win struct {
		BotTrophyMessage  string `json:"botTrophyMessage"`
		UserTrophyMessage string `json:"userTrophyMessage"`
		Message           string `json:"message"`
	} `json:"win,omitempty"`

	ScoreboardMessage string `json:"scoreboardMessage,omitempty"`
}

PingPongCommand structure for game pingpong command

type Router

type Router struct {
	Prefixes      []string
	CaseSensitive bool

	Middleware []Middleware

	Config *Config

	Commands []*Command

	Categories []*Category
}

Router allows easier command handling by routing them from one place, it's even possible to use multiple routers e.g. for different prefixes/languages

func (*Router) AddCommand

func (router *Router) AddCommand(command *Command)

AddCommand Adds command to router

func (*Router) AddMiddleware

func (router *Router) AddMiddleware(middleware Middleware)

AddMiddleware Adds middleware when executing command to router

func (*Router) AddRouterMiddleware

func (router *Router) AddRouterMiddleware(event string, middleware Middleware)

AddRouterMiddleware Adds middleware to router on specified event

func (*Router) Init

func (router *Router) Init(session *discordgo.Session)

Init Initializes router

func (*Router) RefreshCategories

func (router *Router) RefreshCategories()

RefreshCategories refreshes all categories

func (*Router) RefreshCommand

func (router *Router) RefreshCommand(command *Command)

RefreshCommand refreshes given command

func (*Router) RefreshCommands

func (router *Router) RefreshCommands()

RefreshCommands does RefreshCommand to all commands in router

func (*Router) RemoveCommand

func (router *Router) RemoveCommand(command *Command)

RemoveCommand returns function that removes command from maps

type StatsCommand

type StatsCommand struct {
	UserNotFound string `json:"userNotFound,omitempty"`
	Title        string `json:"title,omitempty"`
	CreationDate string `json:"creationDate,omitempty"`
	JoinDate     string `json:"joinDate,omitempty"`
}

StatsCommand structure for stats command

Jump to

Keyboard shortcuts

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