Skip to main content

Display Struct

This command shows you all the available properties of a structure in addition to a link to the Discord docs on that structure.

Trigger

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

Usage

  • -struct <name> - Displays the structure with the name provided. <name> must be one of channel, guild, user, member, or message.
Aliases

Instead of struct, you can also use structure.

Code

{{/*
Shows all the available properties and methods of a structure with a link to the Discord docs on that structure.
See <https://yagpdb-cc.github.io/utilities/display-struct> for more information.

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

{{ $targets := sdict "Channel" .Channel "Guild" .Guild "User" .User "Member" .Member "Message" .Message }}
{{ $resources := sdict
"Channel" "https://discordapp.com/developers/docs/resources/channel#channel-object"
"Guild" "https://discordapp.com/developers/docs/resources/guild#guild-resource"
"User" "https://discordapp.com/developers/docs/resources/user#user-object"
"Member" "https://discordapp.com/developers/docs/resources/guild#guild-member-object"
"Message" "https://discordapp.com/developers/docs/resources/channel#message-object"
}}
{{ $target := 0 }}
{{ $name := "" }}
{{ $input := (parseArgs 1 "**Syntax:** -struct <struct>" (carg "string" "structure")).Get 0 | lower }}
{{ range $struct, $v := $targets }}
{{- if eq (lower $struct) $input }}
{{- $target = $v }}
{{- $name = $struct }}
{{- end -}}
{{ end }}
{{ if $target}}
{{ $json := printf "```go\n%+v```" $target }}
{{ sendMessage nil (cembed
"title" (printf "❯ %s Object" $name)
"url" (index $resources $name)
"description" $json
"color" 14232643
) }}
{{ else }}
Please provide a valid target to view.
{{ end }}

Author

This custom command was written by @jo3-l.