jp

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2024 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var JishoCmd = &framework.Command{
	Name:               "jisho",
	PermissionRequired: 0,
	OwnerOnly:          false,
	Help:               "Searches jisho and displays the first result",
	Exec: func(ctx *framework.Context) error {
		search := ctx.TakeRest()[1:]
		sr, err := j.SearchKeyword(search)
		if err != nil {
			return err
		}
		ctx.ReplyEmbed(JishoResponseAsEmbed(sr))
		return nil
	},
	Setup: nil,
}
View Source
var KanjiCmd = &framework.Command{
	Name:               "kanji",
	PermissionRequired: 0,
	OwnerOnly:          false,
	Help:               "",
	Exec: func(ctx *framework.Context) error {
		kanjiStr, err := ctx.GetArgIndex(0)
		if err != nil {
			return err
		}
		if utf8.RuneCountInString(kanjiStr) > 1 {
			return errors.New("kanji are always one character")
		}
		k, err := j.SearchForKanji(kanjiStr)
		if err != nil {
			return err
		}
		_, err = ctx.ReplyEmbed(TransformKanjiToEmbed(k))
		return err
	},
}

Functions

func JishoResponseAsEmbed

func JishoResponseAsEmbed(sr *jisho.SearchResp) *discordgo.MessageEmbed

func TransformKanjiToEmbed

func TransformKanjiToEmbed(k *jisho.Kanji) *discordgo.MessageEmbed

Types

This section is empty.

Jump to

Keyboard shortcuts

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