Skip to main content

View User Info

This command views information about a user, defaulting to the triggering user.

Differences between this and whois

This command is quite similar to whois but also shows the user's role and uses their display colour. Other than that, there's not much of a difference. It's mainly here for consistency with the other informational commands.

Trigger

Type: Regex
Trigger: \A(-|<@!?204255221017214977>\s*)(user|member)(-?info)?(\s+|\z)

Usage

  • -user - Views information about yourself.
  • -user <user> - Views information about the user provided.
Aliases

Instead of user, you can also use member, memberinfo, member-info, userinfo, or user-info.

Code

{{/*
Views information about a given user / the triggering user.
See <https://yagpdb-cc.github.io/info/user> for more information.

Author: jo3-l <https://github.com/jo3-l>
*/}}

{{/*
Maximum number of roles to show before truncating the rest.

Suppose each role contributes ~30 characters. 30 roles is then 900 characters,
relatively close to the limit of 1024 characters per field value.
*/}}
{{ $ROLE_TRUNCATION_THRESHOLD := 30 }}

{{ $member := .Member }}
{{ $user := .User }}
{{ $args := parseArgs 0 "**Syntax:** `-userinfo [user]`" (carg "member" "target") }}
{{ if $args.IsSet 0 }}
{{ $member = $args.Get 0 }}
{{ $user = $member.User }}
{{ end }}

{{ $roles := $member.Roles }}
{{ $rolesPos := cslice }}
{{ range $roles }}
{{- $role := $.Guild.GetRole . }}
{{- $rolesPos = $rolesPos.Append (sdict "role" $role "position" $role.Position) }}
{{ end }}

{{ $rolesSorted := sort $rolesPos (sdict "reverse" true "key" "position") }}
{{ $omittedCount := 0 }}
{{ if gt (len $rolesPos) $ROLE_TRUNCATION_THRESHOLD }}
{{ $omittedCount = sub (len $rolesPos) $ROLE_TRUNCATION_THRESHOLD }}
{{ $rolesSorted = slice $rolesSorted 0 $ROLE_TRUNCATION_THRESHOLD }}
{{ end }}
{{ $rolesPos = $rolesSorted }}

{{ $roleMentions := cslice }}
{{ range $rolesPos }}
{{- $roleMentions = $roleMentions.Append (printf "<@&%d>" .role.ID) -}}
{{ end }}
{{ $roleMentions = joinStr ", " $roleMentions }}
{{ if $omittedCount }}
{{ $roleMentions = printf "%s [%d roles not shown]" $roleMentions $omittedCount }}
{{ end }}

{{ $bot := "No" }}
{{ if $user.Bot }} {{ $bot = "Yes" }} {{ end }}
{{ $createdAt := snowflakeToTime $user.ID }}

{{ sendMessage nil (cembed
"author" (sdict
"name" (printf "%s (%d)" $user.String $user.ID)
"icon_url" ($user.AvatarURL "256")
)
"fields" (cslice
(sdict "name" "❯ Created At" "value" (printf "<t:%d:F>" $createdAt.Unix))
(sdict "name" "❯ Joined At" "value" (printf "<t:%d:F>" $member.JoinedAt.Parse.Unix))
(sdict "name" "❯ Names" "value" (printf "Global: %s\nNick: %s"
(or $user.Globalname "*None set*") (or $member.Nick "*None set*")
))
(sdict "name" (printf "❯ Roles (%d Total)" (len $member.Roles)) "value" (or $roleMentions "*No roles*"))
(sdict "name" "❯ Bot" "value" $bot)
)
"color" 14232643
"thumbnail" (sdict "url" ($user.AvatarURL "256"))
) }}

Author

This custom command was written by @jo3-l.