bot

package
v0.0.0-...-ec10a6c Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2024 License: GPL-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DonateCommand = command.Command{
	Name:    "donate",
	Aliases: []string{"pix"},
	Handler: func(ctx *command.Context) command.Result {
		t := ctx.T.(*i18n.CommandDonate)

		msg := config.Config.DonateMessage
		embed := model.NewEmbed().
			WithTitle(t.Title.Str()).
			WithDescription(msg)

		return ctx.SuccessEmbed(embed)
	},
}
View Source
var HelpCommand = command.Command{
	Name:    "help",
	Aliases: []string{"h"},
	Parameters: []*command.Parameter{
		{
			Name:     "command",
			Required: false, Type: parameters.ParameterString,
		},
		{
			Name:     "subcommand",
			Required: false, Type: parameters.ParameterString,
		},
	},
	Handler: func(ctx *command.Context) command.Result {
		if len(ctx.Args) == 0 {
			return listCommands(ctx)
		}

		return helpForCommand(ctx)
	},
}
View Source
var LanguageCommand = command.Command{
	Name: "language", Aliases: []string{"lang", "locale"},
	Parameters: []*command.Parameter{
		{
			Name: "language", Type: parameters.ParameterLowerCasedString,
			ValidValuesFunc: listValidLanguages,
			Required:        false,
		},
	},
	Handler: func(ctx *command.Context) command.Result {
		if len(ctx.Args) == 0 {
			return listLanguages(ctx)
		}

		return selectLanguage(ctx)
	},
}
View Source
var PingCommand = command.Command{
	Name: "ping",
	Handler: func(ctx *command.Context) command.Result {
		t := ctx.T.(*i18n.CommandPing)

		latency := formatAPILatency(ctx.Bot)
		if latency == "0" {
			latency = t.StillCalculating.Str(":hourglass_flowing_sand:")
		}

		return ctx.SuccessEmbed(
			model.NewEmbed().
				WithTitle(t.Title.Str(":ping_pong:")).
				WithFooter(t.Footer.Str()).
				WithField(
					t.APILatency.Str(),
					latency,
				),
		)
	},
}
View Source
var ServerCommand = command.Command{
	Name: "server",
	Parameters: []*command.Parameter{
		{
			Name: "language", Type: parameters.ParameterLowerCasedString,
			ValidValuesFunc: listValidLanguages,
			Required:        true,
		},
	},
	Permission: permissions.MustBeAdmin,
	Handler: func(ctx *command.Context) command.Result {
		t := ctx.T.(*i18n.CommandServer)

		langName := i18n.FindLanguageName(ctx.Args[0].(string))

		err := services.Guild.SetGuildOptions(ctx.GuildID, i18n.LanguageName(langName))
		if err != nil {
			slog.Error("Cannot set guild options", tint.Err(err))
			return ctx.Error(t.SomethingWentWrong.Str())
		}

		return ctx.Success(t.ServerOptionsChanged.Str())
	},
}
View Source
var SourceCommand = command.Command{
	Name: "source",
	Handler: func(ctx *command.Context) command.Result {
		t := ctx.T.(*i18n.CommandSource)
		return ctx.Success(t.Description.Str(config.Config.GitRepoURL))
	},
}
View Source
var UptimeCommand = command.Command{
	Name:    "uptime",
	Aliases: []string{"up"},
	Handler: func(ctx *command.Context) command.Result {
		t := ctx.T.(*i18n.CommandUptime)

		uptime := time.Since(*discord.Bot.StartedAt())
		embed := model.NewEmbed().
			WithTitle(t.Title.Str()).
			WithField(t.Uptime.Str(":timer:"), f.DurationAsText(uptime, t.Common)).
			WithField(t.Implementation.Str(":gear:"), discord.Bot.Implementation()).
			WithField(t.Language.Str(":globe_with_meridians:"), t.Meta.DisplayName.Str()).
			WithField(
				t.HostInfoKey.Str(":computer:"),
				t.HostInfoValue.Str(runtime.Version(), runtime.Compiler, runtime.GOOS, runtime.GOARCH,
					k.Is(
						isDocker(),
						" (docker)",
						"",
					),
				),
			).
			WithField(
				t.StartedAt.Str(":star:"),
				t.FormatSimpleDateTime(*discord.Bot.StartedAt()),
			)

		if git.CommitHash != "" {
			embed.WithField(
				t.LastCommit.Str(":floppy_disk:"),
				fmt.Sprintf(
					"[%s (%s)](%s/commit/%s)",
					git.CommitMessage, git.CommitHash[:10], git.RemoteRepo, git.CommitHash,
				),
			)
		}
		return ctx.SuccessEmbed(embed)
	},
}

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