GroundPower YAGPDB β€” Self-Host Additions

SELF-HOST
Reference / Templates / Custom functions added in the GroundPower/yagpdb-selfhost fork β€” not part of upstream YAGPDB.
πŸ“„ Functions (PDF) πŸ“„ Syntax & Data (PDF) ⬇ Download Functions ⬇ Download Syntax πŸ“„ Ekstra Fonksiyonlar (TR) ⬇ Δ°ndir (TR PDF)

HTTP

These functions perform outbound HTTP GET requests from within a custom command. They are a self-host addition and are not present in upstream YAGPDB.

⚠ Limits & Security 5-second timeout, 1 MB maximum response body, http/https schemes only. Requests are SSRF-protected: the target host is resolved and connections to private, loopback, CGNAT, link-local (including cloud metadata 169.254.169.254) and IPv6 ULA addresses are refused β€” so a custom command cannot reach Docker-internal services such as the bot's own database or Redis. There is no URL allow-list; any public URL is permitted, filtered only by the SSRF guard.
Rate Limit httpGet and httpGetJSON share a combined limit of 10 calls per custom command execution (60 on premium), counter http_get. Requests are sent with User-Agent: YAGPDB-selfhost/1.0 (httpGet template fn).

httpGet

{{ $body := httpGet <url> }}

Performs an HTTP GET request to url and returns the response body as a string. Returns an error if the response status is 400 or greater, if the body exceeds 1 MB, or if the URL fails validation (scheme / host / SSRF). The returned string is additionally bounded by the maximum string length.

httpGetJSON

{{ $data := httpGetJSON <url> }}

Like httpGet, but parses the response body as JSON and returns a navigable value: an sdict for JSON objects and a slice for JSON arrays, so you can traverse it with .Field access or the index function. Returns an error on a status of 400 or greater, or on invalid JSON.

{{ $data := httpGetJSON "https://example.com/champions.json" }}
{{ $champ := index $data.champions "aatrox" }}
{{ $champ.name }}

Member β€” Voice Moderation

These functions allow custom commands to manage voice channel members directly: move them between voice channels, disconnect them, server-mute / unmute, and server-deafen / undeafen. They complement the read-only getMemberVoiceState helper.

Bot Permissions The bot must have the corresponding voice permission for each action: MOVE_MEMBERS for moveMember, MUTE_MEMBERS for muteMember/unmuteMember, and DEAFEN_MEMBERS for deafenMember/undeafenMember. The bot must also be higher in the role hierarchy than the target member.
⚠ Target Must Be Connected All five functions require the target member to currently be connected to a voice channel. If they are not, Discord returns an error which is propagated to your custom command β€” wrap calls in try/catch to handle this gracefully.
Rate Limit These functions share a combined limit of 50 calls per custom command execution (counter voice_mod, cost 1 each). Discord also enforces its own per-route rate limits on guild member modifications.

moveMember

{{ moveMember <target> <channel> }}

Moves a member to the specified voice channel. Pass nil or 0 as the channel argument to disconnect the member from voice instead of moving them.

muteMember

{{ muteMember <target> }}

Server-mutes the specified member. The target must currently be in a voice channel.

unmuteMember

{{ unmuteMember <target> }}

Removes a server-mute from the specified member.

deafenMember

{{ deafenMember <target> }}

Server-deafens the specified member. The target must currently be in a voice channel.

undeafenMember

{{ undeafenMember <target> }}

Removes a server-deafen from the specified member.

Examples

Move a member to the AFK channel:

{{ if not (hasPermissions .Permissions.MoveMembers) }}
  You do not have permission to move members.
  {{ return }}
{{ end }}
{{ $args := parseArgs 1 "" (carg "member" "target") }}
{{ $target := ($args.Get 0).User }}
{{ $vs := getMemberVoiceState $target }}
{{ if not $vs }}
  {{ printf "%s is not currently in a voice channel." $target.Mention }}
  {{ return }}
{{ end }}
{{ try }}
  {{ moveMember $target .Guild.AfkChannelID }}
  {{ printf "%s was moved to the AFK channel." $target.Mention }}
{{ catch }}
  Error: {{ .Error }}
{{ end }}

Disconnect a member from voice:

{{ moveMember .User nil }}

Toggle mute on the triggering user:

{{ $vs := getMemberVoiceState .User }}
{{ if not $vs }}Not in voice.{{ return }}{{ end }}
{{ if $vs.Mute }}
  {{ unmuteMember .User }}Unmuted {{ .User.Mention }}.
{{ else }}
  {{ muteMember .User }}Muted {{ .User.Mention }}.
{{ end }}

Voice State (data type)

Available as the return value of getMemberVoiceState and as the elements of .Guild.VoiceStates (type discordgo.VoiceState). getMemberVoiceState returns nil if the member is not connected to a voice channel.

FieldDescription
.ChannelIDThe ID of the voice channel the member is connected to, of type int64.
.UserIDThe ID of the member this voice state belongs to, of type int64.
.GuildIDThe guild ID on which the voice state exists, of type int64.
.SessionIDThe voice session ID, of type string.
.MuteWhether the member is server-muted (bool). Set / cleared by muteMember/unmuteMember.
.DeafWhether the member is server-deafened (bool). Set / cleared by deafenMember/undeafenMember.
.SelfMuteWhether the member muted themselves (bool).
.SelfDeafWhether the member deafened themselves (bool).
.SelfStreamWhether the member is streaming with Go Live (bool).
.SelfVideoWhether the member has their camera turned on (bool).
.SuppressWhether the member is suppressed, e.g. a stage-channel audience member (bool).
Used By These fields back the voice moderation functions above. For example, {{ (getMemberVoiceState .User).Mute }} reports whether the triggering user is server-muted.

Members

Bulk-fetch guild members from the Discord API. Self-host addition, not present in upstream YAGPDB.

getGuildMembers

{{ getGuildMembers [key value ...] }}

Fetches members of the current guild from the Discord API and returns a slice of *discordgo.Member. Called with no arguments it returns up to 25 members of the current guild. Arguments are passed as key/value pairs.

KeyDescription
limitHow many members to fetch. Default 25, minimum 1, maximum 10000.
afterPagination β€” return members with an ID greater than this user ID.
guildidFetch from another guild instead of the current one. Bot admin only.
{{ $members := getGuildMembers "limit" 100 }}
Fetched: {{ len $members }}
{{ range $members }}
  {{ .User.Username }}
{{ end }}
Rate Limit Counter guild_getMembers, cost 2 per call.

Direct Messages

In upstream YAGPDB sendDM can only DM the user who triggered the command. This fork extends it so that when the first argument resolves to a user, the DM is sent to that arbitrary user.

sendDM

{{ sendDM <userID> <message> }}   {{/* any user */}}
{{ sendDM <message> }}            {{/* the triggering user */}}

Called with two or more arguments where the first resolves to a user (ID, mention, or user object), the message is sent to that user (resolved via TargetUserID). Called with a single argument it falls back to the stock behaviour and DMs the command invoker. The message may be a string or a cembed; nothing is sent if the content is empty.

{{/* DM a specific user */}}
{{ sendDM 140574551087120384 "Someone just won the game!" }}

{{/* With a variable + printf */}}
{{ $owner := 140574551087120384 }}
{{ sendDM $owner (printf "%s won, code: %d" .User.Username (randInt 1000 9999)) }}

{{/* Stock behaviour: DM the invoker */}}
{{ sendDM "A private message just for you." }}
Self-Host Note This modification lives in the deployed build; upstream (and the GitHub master branch) ship the stock triggerer-only sendDM.