kuma

package module
v2.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2024 License: MIT Imports: 11 Imported by: 0

README


License GoDoc

KumaEngine

Personal discordgo extend library

How to use

1. Installation
go get -u github.com/devproje/kuma-engine-v2
2. Example code
package main

import (
	"flag"
	"strconv"

	"github.com/bwmarrin/discordgo"
	"github.com/devproje/kuma-engine"
	"github.com/devproje/kuma-engine/v2/command"
	"github.com/devproje/kuma-engine/v2/utils"
	"github.com/devproje/plog/log"
)

var (
	token = *flag.String("token", "", "Type Discord Token")
)

func ready(session *discordgo.Session, ready *discordgo.Ready) {
	log.Infof("Logged in as %s", ready.User.String())
}

func main() {
	builder := kuma.EngineBuilder()
	builder.SetToken(token)
	builder.AddEventOnceListener(ready)
	builder.SetKumaInfo(true)

	err := builder.Build()
	if err != nil {
		log.Fatalln(err)
	}
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Engine added in v2.1.0

type Engine struct {
	Token   string
	Session *discordgo.Session
	// contains filtered or unexported fields
}

func EngineBuilder

func EngineBuilder() *Engine

EngineBuilder Create a new Engine instance

func (*Engine) AddCommand added in v2.1.0

func (k *Engine) AddCommand(command command.Executor)

AddCommand Add a new command in inner handler

func (*Engine) AddCommandHandler added in v2.1.0

func (k *Engine) AddCommandHandler(handler *command.Handler)

AddCommandHandler Add a new command handler

func (*Engine) AddEventListener added in v2.1.0

func (k *Engine) AddEventListener(ev interface{})

AddEventListener Add a new event listener

func (*Engine) AddEventOnceListener added in v2.1.0

func (k *Engine) AddEventOnceListener(ev interface{})

AddEventOnceListener Add a new event listener once

func (*Engine) AddLoggingFile added in v2.1.0

func (k *Engine) AddLoggingFile(name string)

AddLoggingFile Add a new logging file

func (*Engine) Build added in v2.1.0

func (k *Engine) Build() error

Build Building the bot session

func (*Engine) Close added in v2.1.0

func (k *Engine) Close() error

Close Closing bot session

func (*Engine) CreateInterruptSignal added in v2.1.0

func (k *Engine) CreateInterruptSignal()

CreateInterruptSignal Create an interrupt signal

func (*Engine) DropCommand added in v2.1.0

func (k *Engine) DropCommand(name string)

DropCommand Remove a command in inner handler

func (*Engine) GetShard added in v2.1.0

func (k *Engine) GetShard(shardId int) (*discordgo.Session, error)

func (*Engine) GetShardCount added in v2.1.0

func (k *Engine) GetShardCount() int

GetShardCount Get the bot shard count

func (*Engine) IsKumaInfo added in v2.1.0

func (k *Engine) IsKumaInfo() bool

IsKumaInfo Check if the kuma info command is enabled

func (*Engine) RemoveCommandHandler added in v2.1.0

func (k *Engine) RemoveCommandHandler(handler *command.Handler)

RemoveCommandHandler Remove a command handler

func (*Engine) SetIntent added in v2.1.0

func (k *Engine) SetIntent(intent discordgo.Intent)

SetIntent Set the bot intents

func (*Engine) SetKumaInfo added in v2.1.0

func (k *Engine) SetKumaInfo(value bool)

SetKumaInfo Set the kuma info command

func (*Engine) SetMode added in v2.1.0

func (k *Engine) SetMode(m mode.EngineMode)

SetMode Set the engine mode

func (*Engine) SetShardCount added in v2.1.0

func (k *Engine) SetShardCount(shardCount int)

SetShardCount Set the bot shard count

func (*Engine) SetToken added in v2.1.0

func (k *Engine) SetToken(token string)

SetToken Set the bot token

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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