anothi

package module
v0.0.0-...-3c8f0bd Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2020 License: BSD-3-Clause Imports: 4 Imported by: 0

README

* Anothi

Anothi is a command framework for [[https://github.com/bwmarrin/discordgo][discordgo]].

* Usage

#+BEGIN_SRC go
package main

import (
	"yab/commands"

	"github.com/bwmarrin/discordgo"
	"github.com/ratsclub/anothi"
)

var f = anothi.New()

func init() {
	f.Prefix("!").
		OnNotFound(commands.OnNotFound).
		OnError(commands.OnError).
		OnNoPermission(commands.OnNoPermission)

	f.AddCommand("del", commands.BanUser, discordgo.PermissionAdministrator)
	f.AddCommand("kick", commands.KickUser, discordgo.PermissionKickMembers)
	f.AddCommand("ban", commands.BanUser, discordgo.PermissionBanMembers)

	dg.AddHandler(f.OnMessageCreate)
}
#+END_SRC

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Framework

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

Framework determines all properties of your commands

func New

func New() Framework

New returns a new framework instance

func (*Framework) AddCommand

func (f *Framework) AddCommand(name string, fun callbackFunction, permission int)

AddCommand adds a new command

func (*Framework) OnError

func (f *Framework) OnError(fun fallbackFunction) *Framework

OnError will set a default function that will be called when a command raises an error

func (*Framework) OnMessageCreate

func (f *Framework) OnMessageCreate(s *discordgo.Session, m *discordgo.MessageCreate)

OnMessageCreate is the callback used to tie the framework with discordgo

func (*Framework) OnNoPermission

func (f *Framework) OnNoPermission(fun fallbackFunction) *Framework

OnNoPermission will set a default function that will be called when a user does not have permission for a command

func (*Framework) OnNotFound

func (f *Framework) OnNotFound(fun fallbackFunction) *Framework

OnNotFound will set a default function that will be called when a command doest not exist

func (*Framework) Prefix

func (f *Framework) Prefix(prefix string) *Framework

Prefix will set your bot prefix

Jump to

Keyboard shortcuts

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