tools

package
v0.0.0-...-91b6c6a Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2024 License: GPL-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CNPJCommand = command.Command{
	Name: "cnpj",
	Handler: func(ctx *command.Context) command.Result {
		t := ctx.T.(*i18n.CommandCNPJ)

		cnpj := doc.GenerateCNPJ()
		components := cnpjMaskRe.FindStringSubmatch(cnpj)
		maskedCNPJ := fmt.Sprintf(
			"%s.%s.%s/%s-%s",
			components[1], components[2], components[3], components[4], components[5],
		)

		return ctx.SuccessEmbed(
			model.NewEmbed().
				WithTitle(t.Title.Str()).
				WithField(t.WithoutMask.Str(), cnpj).
				WithField(t.WithMask.Str(), maskedCNPJ),
		)
	},
}
View Source
var CPFCommand = command.Command{
	Name: "cpf",
	Handler: func(ctx *command.Context) command.Result {
		t := ctx.T.(*i18n.CommandCPF)

		cpf := doc.GenerateCPF()
		components := cpfMaskRe.FindStringSubmatch(cpf)
		maskedCPF := fmt.Sprintf(
			"%s.%s.%s-%s",
			components[1], components[2], components[3], components[4],
		)

		return ctx.SuccessEmbed(
			model.NewEmbed().
				WithTitle(t.Title.Str()).
				WithField(t.WithoutMask.Str(), cpf).
				WithField(t.WithMask.Str(), maskedCPF),
		)
	},
}
View Source
var PasswordCommand = command.Command{
	Name: "password", Aliases: []string{"pass"},
	Ephemeral: true,
	Parameters: []*command.Parameter{
		{Name: "length", Type: parameters.ParameterInt, Required: false},
	},
	Handler: func(ctx *command.Context) command.Result {
		t := ctx.T.(*i18n.CommandPassword)

		length := 10
		if len(ctx.Args) == 1 {
			length = ctx.Args[0].(int)
		}
		password, err := generatePassword(length)

		if err != nil {
			slog.Error("Cannot generate password", tint.Err(err))
			return ctx.Error(ctx.Lang.SomethingWentWrong.Str())
		}

		embed := model.NewEmbed().
			WithTitle(t.Title.Str()).
			WithDescription(
				t.Description.Str(
					length, password,
				),
			)

		return ctx.SuccessEmbed(embed)
	},
}
View Source
var Tools = command.Category{
	Name:  "tools",
	Emoji: "🔧",
	Commands: []*command.Command{
		&UUIDCommand, &CPFCommand, &CNPJCommand, &PasswordCommand,
	},
}
View Source
var UUIDCommand = command.Command{
	Name: "uuid",
	Handler: func(ctx *command.Context) command.Result {
		id := uuid.New()
		return ctx.SuccessEmbed(
			model.NewEmbed().
				WithTitle("UUID v4").
				WithDescription(id.String()),
		)
	},
}

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

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