Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MakeEmbed ¶
func MakeEmbed(config *Config, base *discordgo.MessageEmbed) *discordgo.MessageEmbed
MakeEmbed returns a Discord embed with the style of the bot
func OpenDatabase ¶
Types ¶
type Bot ¶
type Bot struct { // Name of the bot Name string // The Discord client associated with the bot Client *discordgo.Session // A list of all the commands available on the bot Commands map[string]*Command // The mongodb database attached to the bot (if used) Database *mongo.Client // The Redis cache attached to the bot (if used) Cache *redis.Client // The configuration of the bot, as defined in the corresponding file Config *Config // The profile of the bot User *discordgo.User }
Bot represents the Discord bot with its assets
func RegisterBot ¶
RegisterBot creates a new instance of the Discord Bot
func (*Bot) ExecuteCommand ¶
func (bot *Bot) ExecuteCommand(command *Command, arguments []string, message *discordgo.MessageCreate)
ExecuteCommand executes the command parsed in the OnCommand function
func (*Bot) OnCommand ¶
func (bot *Bot) OnCommand(session *discordgo.Session, message *discordgo.MessageCreate)
OnCommand reacts to a newly-created message and treats it
func (*Bot) RegisterCommand ¶
type Command ¶
type Command struct { // Description of the command (e.g : Prints weather for a specific location) Description string // Usage of the command (e.g : weather <location>) Usage string // Category of the command, as defined in the configuration (e.g : utilities) Category string // An alias to another command (e.g : w) Alias string // Choose if the command is shown in the help or not Show bool // Whether the bot should listen to the command in public channels ListenInPublic bool // Whether the bot should listen to the command in direct messages ListenInDM bool // Lock the command only for certain channels Channels []int // Lock the command only for certain user roles Roles []int // Lock the command only for certain members on the server Members []int // Action to execute if the command is triggered Execute func(arguments []string, bot Bot, message *discordgo.MessageCreate) (err error) }
Command represents a command that can be executed by a user
type Config ¶
type Config struct { // Information for the development Dev struct { // Activates the debug mode, so the bot logs everything Debug bool // Version of the bot Version string // Information about the maintainer Maintainer struct { Name string Link string } } // Information about the bot itself Bot struct { // Its name Name string // The token to connect to Discord Token string // Discord's client ID ID string // An illustration, for example its logo Illustration string // A website on which users can go for further information Website string // Prefix for all the commands (e.g: !) Prefix string // The color theme of the bot (e.g: #b7c1c) Color int } // A list of command categories Categories map[string]struct { // Their name, displayed in the help command Name string // Their emoji, displayed in the help command Emoji string } // Some assets user can add Assets map[string]string // Information to connect to the MongoDB database Database struct { // Address of the database (e.g: localhost) Address string // Port of the database (e.g: 1234) Port int // Username to connect to the database (e.g: onyxcord) Username string // Password for this username Password string // Database to use Database string // Database to connect from (e.g: onyxcord) AuthSource string `yaml:"auth_source"` } Cache struct { // Address of the cache (e.g: localhost) Address string // Port of the database (e.g: 6379) Port string } }
Config represents the configuration stored in the file
Source Files ¶
Click to show internal directories.
Click to hide internal directories.