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 ¶
Click to show internal directories.
Click to hide internal directories.