stdcommands

package
v0.0.0-...-f0c0f71 Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2022 License: MIT Imports: 24 Imported by: 0

README

Standard Commands

Standard Commands is a space to store and develop the different commands of the bot, which will be used by the users with the prefix provided to the application.

Make a Command

The commands are stored in a folder that represents a single package, then these packages must be imported into the stdcommands.go file. Stdcommands load the different commands when the bot is started.

Each command is imported as a variable containing a WafferCommand struct, provided by the commands package located at ./pkg/plugins/commands/commands.go.

Example

package ping

import (
	"fmt"

	"github.com/bwmarrin/discordgo"
	"github.com/nicolito128/waffer/pkg/plugins"
	"github.com/nicolito128/waffer/pkg/plugins/commands"
)

var Command = &commands.WafferCommand{
	Plugin: &plugins.Plugin[*discordgo.MessageCreate]{
		Name:    "ping",
		Type:    plugins.MessageCreateType,
		Handler: Handler,
	},

	Data: &commands.CommandData{
		Name:        "ping",
		Description: "Ping!",
		Permissions: &commands.CommandPermissions{
			AllowDM: true,
			Require: discordgo.PermissionSendMessages,
		},
	},
}

func Handler(s *discordgo.Session, m *discordgo.MessageCreate) {
	s.ChannelMessageSend(m.ChannelID, "Pong!")
}

Directories

Path Synopsis
fun
dog
images
info
util
say

Jump to

Keyboard shortcuts

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