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 was on", 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 } candidates := make([]*Candidate, 0, 0) bot.State.RLock() for _, v := range bot.State.Guilds { bot.State.RUnlock() v.RLock() if candidate := CheckGuild(v, nameToMatch, userIDToMatch); candidate != nil { candidates = append(candidates, candidate) } v.RUnlock() bot.State.RLock() if len(candidates) > 1000 { break } } bot.State.RUnlock() if len(candidates) < 1 { return "No matches", nil } resp := "" for _, candidate := range candidates { resp += fmt.Sprintf("`%d`: **%s**", candidate.ID, candidate.Name) if candidate.UserMatch { resp += fmt.Sprintf(" (owner: `%t`, admin: `%t`, mod: `%t`)", candidate.Owner, candidate.Admin, candidate.Mod) } resp += "\n" } return resp, nil }), }
Functions ¶
This section is empty.
Types ¶
Click to show internal directories.
Click to hide internal directories.