godiscordutil

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2022 License: MIT Imports: 6 Imported by: 0

README

godiscordutil

Go package that provides a (small but growing) number of functions that may be useful for discord bots. None of these are anything groundbreaking, but I have used these in multiple projects and so feel that they deserve their own repo.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CommandToFunc

func CommandToFunc(
	command string,
	arguments []string,
	cmdMap map[string]BotFunc,
	db *sql.DB,
) string

CommandToFunc passes command and argument parameters through Map parameter, returning the resulting function from the map

func GenTable

func GenTable(data RawTable) string

GenTable generates simple ascii table as string

func IsCommand

func IsCommand(message string, flag string) bool

IsCommand verifies that a given message is meant for this bot

func IsOwnMessage

func IsOwnMessage(
	s *discordgo.Session,
	m *discordgo.MessageCreate,
) bool

IsOwnMessage verifies that a given message is not from this bot

func ParseMessage

func ParseMessage(
	message string,
	flag string,
) (command string, args []string)

ParseMessage splits message into command (scrubbed of bot flag) And list of arguments

Types

type BotFunc

type BotFunc func(*sql.DB, []string) string

BotFunc is an abstract type for functions that serve a Discord bot

type RawTable

type RawTable [][]string

RawTable contains the data to be inserted into ascii table

Jump to

Keyboard shortcuts

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