findserver

package
v1.20.6 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2019 License: MIT Imports: 9 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Command = &commands.YAGCommand{
	Cooldown:             2,
	CmdCategory:          commands.CategoryDebug,
	HideFromCommandsPage: true,
	Name:                 "findserver",
	Aliases:              []string{"findservers"},
	Description:          "Looks for a server by server name or the servers a user owns",
	HideFromHelp:         true,
	ArgSwitches: []*dcmd.ArgDef{
		&dcmd.ArgDef{Switch: "name", Name: "name", Type: dcmd.String, Default: ""},
		&dcmd.ArgDef{Switch: "user", Name: "user", Type: dcmd.UserID, Default: 0},
	},
	RunFunc: util.RequireBotAdmin(func(data *dcmd.Data) (interface{}, error) {
		nameToMatch := strings.ToLower(data.Switch("name").Str())
		userIDToMatch := data.Switch("user").Int64()

		if userIDToMatch == 0 && nameToMatch == "" {
			return "-name or -user not provided", nil
		}

		var whereQM qm.QueryMod
		if userIDToMatch != 0 {
			whereQM = qm.Where("owner_id = ?", userIDToMatch)
		} else {
			whereQM = qm.Where("name ILIKE ?", "%"+nameToMatch+"%")
		}

		results, err := models.JoinedGuilds(qm.Where("left_at is null"), whereQM, qm.OrderBy("id desc"), qm.Limit(250)).AllG(data.Context())
		if err != nil {
			return nil, err
		}

		resp := ""
		for _, v := range results {
			resp += fmt.Sprintf("`%d`: **%s**\n", v.ID, v.Name)
		}

		resp += fmt.Sprintf("%d results", len(results))

		return resp, nil
	}),
}

Functions

This section is empty.

Types

type Candidate

type Candidate struct {
	ID   int64
	Name string

	UserMatch bool
	Owner     bool
	Admin     bool
	Mod       bool
}

func CheckGuild

func CheckGuild(gs *dstate.GuildState, nameToMatch string, userToMatch int64) *Candidate

Jump to

Keyboard shortcuts

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