PageSourceSearch

https://message.style/assets/js/980c5e59.8c4a4cf7.js

js message.style collected 2026-09-25 22:07:25 UTC 12,591 bytes, 1 lines download raw bytes

1"use strict";(self.webpackChunkembedg_site=self.webpackChunkembedg_site||[]).push([[2791],{1385:(e,t,n)=>{n.d(t,{R:()=>i,x:()=>a});var s=n(9474);const r={},d=s.createContext(r);function i(e){const t=s.useContext(d);return s.useMemo(function(){return"function"==typeof e?e(t):{...t,...e}},[t,e])}function a(e){let t;return t=e.disableParentContext?"function"==typeof e.components?e.components(r):e.components||r:i(e.components),s.createElement(d.Provider,{value:t},e.children)}},5594:(e,t,n)=>{n.d(t,{A:()=>s});const s=n.p+"assets/images/variables-response-178dd73c92d82a61ddc3d4514de1b9b2.png"},7007:(e,t,n)=>{n.r(t),n.d(t,{assets:()=>o,contentTitle:()=>a,default:()=>l,frontMatter:()=>i,metadata:()=>s,toc:()=>h});const s=JSON.parse('{"id":"guides/variables","title":"Message Variables","description":"List of message variables in Embed Generator, like the user mention, member count or channel name, with loop and if-else examples for custom commands and component responses.","source":"@site/docs/guides/variables.md","sourceDirName":"guides","slug":"/guides/variables","permalink":"/docs/guides/variables","draft":false,"unlisted":false,"editUrl":"https://github.com/merlinfuchs/embed-generator/tree/main/embedg-site/docs/guides/variables.md","tags":[],"version":"current","sidebarPosition":6,"frontMatter":{"sidebar_position":6,"description":"List of message variables in Embed Generator, like the user mention, member count or channel name, with loop and if-else examples for custom commands and component responses."},"sidebar":"tutorialSidebar","previous":{"title":"Custom Commands","permalink":"/docs/guides/custom-commands"},"next":{"title":"Migrating from Discohook","permalink":"/docs/guides/migrating-discohook"}}');var r=n(3274),d=n(1385);const i={sidebar_position:6,description:"List of message variables in Embed Generator, like the user mention, member count or channel name, with loop and if-else examples for custom commands and component responses."},a="Message Variables",o={},h=[{value:"List of Variables",id:"list-of-variables",level:2},{value:"Advanced Usage",id:"advanced-usage",level:2},{value:"Loop Example",id:"loop-example",level:3},{value:"If-Else Example",id:"if-else-example",level:3}];function c(e){const t={a:"a",code:"code",h1:"h1",h2:"h2",h3:"h3",header:"header",img:"img",p:"p",pre:"pre",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",...(0,d.R)(),...e.components};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(t.header,{children:(0,r.jsx)(t.h1,{id:"message-variables",children:"Message Variables"})}),"\n",(0,r.jsx)(t.p,{children:"Message variables are a way to dynamically adjust the content of your message based on the context. This is especially useful in responses to custom commands and interactive components."}),"\n",(0,r.jsxs)(t.p,{children:["To use a variable in your message just put ",(0,r.jsx)(t.code,{children:"{{ .VariableName }}"})," where you want the value to appear. For example put ",(0,r.jsx)(t.code,{children:"{{ .Interaction.User.Mention }}"})," in your message content to ping the user that has used a command.\nPlease notice the dot (",(0,r.jsx)(t.code,{children:"."}),") in front of each variable name!"]}),"\n",(0,r.jsxs)(t.p,{children:[(0,r.jsx)(t.img,{alt:"Variables in Button",src:n(8843).A+"",width:"1262",height:"1208"}),"\n",(0,r.jsx)(t.img,{alt:"Variables in response",src:n(5594).A+"",width:"1808",height:"1094"})]}),"\n",(0,r.jsx)(t.h2,{id:"list-of-variables",children:"List of Variables"}),"\n",(0,r.jsxs)(t.table,{children:[(0,r.jsx)(t.thead,{children:(0,r.jsxs)(t.tr,{children:[(0,r.jsx)(t.th,{children:"Variable"}),(0,r.jsx)(t.th,{children:"Type"}),(0,r.jsx)(t.th,{children:"Description"})]})}),(0,r.jsxs)(t.tbody,{children:[(0,r.jsxs)(t.tr,{children:[(0,r.jsx)(t.td,{children:".Interaction.User"}),(0,r.jsx)(t.td,{children:"text"}),(0,r.jsx)(t.td,{children:"Mention the user that has used the command or interactive component."})]}),(0,r.jsxs)(t.tr,{children:[(0,r.jsx)(t.td,{children:".Interaction.User.ID"}),(0,r.jsx)(t.td,{children:"text"}),(0,r.jsx)(t.td,{children:"The ID of the user that has used the command or interactive component."})]}),(0,r.jsxs)(t.tr,{children:[(0,r.jsx)(t.td,{children:".Interaction.User.Name"}),(0,r.jsx)(t.td,{children:"text"}),(0,r.jsx)(t.td,{children:"The display name or username of the user that has used the command or interactive component."})]}),(0,r.jsxs)(t.tr,{children:[(0,r.jsx)(t.td,{children:".Interaction.User.Username"}),(0,r.jsx)(t.td,{children:"text"}),(0,r.jsx)(t.td,{children:"The username of the user that has used the command or interactive component."})]}),(0,r.jsxs)(t.tr,{children:[(0,r.jsx)(t.td,{children:".Interaction.User.Discriminator"}),(0,r.jsx)(t.td,{children:"text"}),(0,r.jsx)(t.td,{children:"The discriminator of the user that has used the command or interactive component."})]}),(0,r.jsxs)(t.tr,{children:[(0,r.jsx)(t.td,{children:".Interaction.User.Avatar"}),(0,r.jsx)(t.td,{children:"text"}),(0,r.jsx)(t.td,{children:"The avatar hash of the user that has used the command or interactive component."})]}),(0,r.jsxs)(t.tr,{children:[(0,r.jsx)(t.td,{children:".Interaction.User.AvatarURL"}),(0,r.jsx)(t.td,{children:"text"}),(0,r.jsx)(t.td,{children:"The avatar URL of the user that has used the command or interactive component."})]}),(0,r.jsxs)(t.tr,{children:[(0,r.jsx)(t.td,{children:".Interaction.User.GlobalName"}),(0,r.jsx)(t.td,{children:"text"}),(0,r.jsx)(t.td,{children:"The display name of the user that has used the command or interactive component."})]}),(0,r.jsxs)(t.tr,{children:[(0,r.jsx)(t.td,{children:".Interaction.User.Mention"}),(0,r.jsx)(t.td,{children:"text"}),(0,r.jsx)(t.td,{children:"Mention the user that has used the command or interactive component."})]}),(0,r.jsxs)(t.tr,{children:[(0,r.jsx)(t.td,{children:".Server"}),(0,r.jsx)(t.td,{children:"text"}),(0,r.jsx)(t.td,{children:"The name of the server where the command or interactive component has been used."})]}),(0,r.jsxs)(t.tr,{children:[(0,r.jsx)(t.td,{children:".Server.ID"}),(0,r.jsx)(t.td,{children:"text"}),(0,r.jsx)(t.td,{children:"The ID of the server where the command or interactive component has been used."})]}),(0,r.jsxs)(t.tr,{children:[(0,r.jsx)(t.td,{children:".Server.Name"}),(0,r.jsx)(t.td,{children:"text"}),(0,r.jsx)(t.td,{children:"The name of the server where the command or interactive component has been used."})]}),(0,r.jsxs)(t.tr,{children:[(0,r.jsx)(t.td,{children:".Server.Description"}),(0,r.jsx)(t.td,{children:"text"}),(0,r.jsx)(t.td,{children:"The description of the server where the command or interactive component has been used."})]}),(0,r.jsxs)(t.tr,{children:[(0,r.jsx)(t.td,{children:".Server.Icon"}),(0,r.jsx)(t.td,{children:"text"}),(0,r.jsx)(t.td,{children:"The icon hash of the server where the command or interactive component has been used."})]}),(0,r.jsxs)(t.tr,{children:[(0,r.jsx)(t.td,{children:".Server.IconURL"}),(0,r.jsx)(t.td,{children:"text"}),(0,r.jsx)(t.td,{children:"The icon URL of the server where the command or interactive component has been used."})]}),(0,r.jsxs)(t.tr,{children:[(0,r.jsx)(t.td,{children:".Server.Banner"}),(0,r.jsx)(t.td,{children:"text"}),(0,r.jsx)(t.td,{children:"The banner hash of the server where the command or interactive component has been used."})]}),(0,r.jsxs)(t.tr,{children:[(0,r.jsx)(t.td,{children:".Server.BannerURL"}),(0,r.jsx)(t.td,{children:"text"}),(0,r.jsx)(t.td,{children:"The banner URL of the server where the command or interactive component has been used."})]}),(0,r.jsxs)(t.tr,{children:[(0,r.jsx)(t.td,{children:".Server.MemberCount"}),(0,r.jsx)(t.td,{children:"text"}),(0,r.jsx)(t.td,{children:"The approximate member count of the server where the command or interactive component has been used. (might be inaccurate)"})]}),(0,r.jsxs)(t.tr,{children:[(0,r.jsx)(t.td,{children:".Server.BoostCount"}),(0,r.jsx)(t.td,{children:"text"}),(0,r.jsx)(t.td,{children:"The boost count of the server where the command or interactive component has been used."})]}),(0,r.jsxs)(t.tr,{children:[(0,r.jsx)(t.td,{children:".Server.BoostLevel"}),(0,r.jsx)(t.td,{children:"text"}),(0,r.jsx)(t.td,{children:"The boost level of the server where the command or interactive component has been used."})]}),(0,r.jsxs)(t.tr,{children:[(0,r.jsx)(t.td,{children:".Channel"}),(0,r.jsx)(t.td,{children:"text"}),(0,r.jsx)(t.td,{children:"Mention the channel where the command or interactive component has been used."})]}),(0,r.jsxs)(t.tr,{children:[(0,r.jsx)(t.td,{children:".Channel.ID"}),(0,r.jsx)(t.td,{children:"text"}),(0,r.jsx)(t.td,{children:"The ID of the channel where the command or interactive component has been used."})]}),(0,r.jsxs)(t.tr,{children:[(0,r.jsx)(t.td,{children:".Channel.Name"}),(0,r.jsx)(t.td,{children:"text"}),(0,r.jsx)(t.td,{children:"The name of the channel where the command or interactive component has been used."})]}),(0,r.jsxs)(t.tr,{children:[(0,r.jsx)(t.td,{children:".Channel.Mention"}),(0,r.jsx)(t.td,{children:"text"}),(0,r.jsx)(t.td,{children:"Mention the channel where the command or interactive component has been used."})]}),(0,r.jsxs)(t.tr,{children:[(0,r.jsx)(t.td,{children:".Channel.Topic"}),(0,r.jsx)(t.td,{children:"text"}),(0,r.jsx)(t.td,{children:"The topic of the channel where the command or interactive component has been used."})]}),(0,r.jsxs)(t.tr,{children:[(0,r.jsx)(t.td,{children:".Interaction.Command"}),(0,r.jsx)(t.td,{children:"text"}),(0,r.jsx)(t.td,{children:"Mention the command that was used."})]}),(0,r.jsxs)(t.tr,{children:[(0,r.jsx)(t.td,{children:".Interaction.Command.ID"}),(0,r.jsx)(t.td,{children:"text"}),(0,r.jsx)(t.td,{children:"The ID of the command that was used."})]}),(0,r.jsxs)(t.tr,{children:[(0,r.jsx)(t.td,{children:".Interaction.Command.Name"}),(0,r.jsx)(t.td,{children:"text"}),(0,r.jsx)(t.td,{children:"The name of the command that was used."})]}),(0,r.jsxs)(t.tr,{children:[(0,r.jsx)(t.td,{children:".Interaction.Command.Args.my_arg"}),(0,r.jsx)(t.td,{children:"text / user / channel / role / attachment"}),(0,r.jsxs)(t.td,{children:["The value of one of the command arguments. Replace ",(0,r.jsx)(t.code,{children:"my_arg"})," with the name of the argument. Depending on the type of the command argument this might have sub variables like ",(0,r.jsx)(t.code,{children:".Interaction.Command.Args.my_arg.ID"})," for the id of a user."]})]})]})]}),"\n",(0,r.jsx)(t.h2,{id:"advanced-usage",children:"Advanced Usage"}),"\n",(0,r.jsxs)(t.p,{children:["Under the hood message variables are powered by ",(0,r.jsx)(t.a,{href:"https://pkg.go.dev/text/template",children:"Go Templates"})," which supports more than just basic variables. You can do if statements, loops, and a lot more!"]}),"\n",(0,r.jsxs)(t.p,{children:["Below there are some example of what you can do, but for more information pleae read the ",(0,r.jsx)(t.a,{href:"https://pkg.go.dev/text/template",children:"Go Template documentation"}),"."]}),"\n",(0,r.jsx)(t.h3,{id:"loop-example",children:"Loop Example"}),"\n",(0,r.jsx)(t.p,{children:"List the roles of the user that has used the custom command or interactive component:"}),"\n",(0,r.jsx)(t.pre,{children:(0,r.jsx)(t.code,{className:"language-go",children:"{{ range .Interaction.User.Roles -}}\n   {{- .Mention -}}\n{{- end }}\n"})}),"\n",(0,r.jsxs)(t.p,{children:["Notice the dot (",(0,r.jsx)(t.code,{children:"."}),", also known as cursor) encompasses all active data available for use in the templating system, in other words it always refers to current context. In the loop it refers to the current item, in this case one of the roles."]}),"\n",(0,r.jsxs)(t.p,{children:["Also notice the dash (",(0,r.jsx)(t.code,{children:"-"}),") inside each of the actions which is used to strip all whitespace
1s from that side."]}),"\n",(0,r.jsx)(t.h3,{id:"if-else-example",children:"If-Else Example"}),"\n",(0,r.jsx)(t.p,{children:"Check if the server has more than 5 boosts and respond based on it."}),"\n",(0,r.jsx)(t.pre,{children:(0,r.jsx)(t.code,{className:"language-go",children:"{{ if gt .Server.BoostCount 5 -}}\n   Your server has a lot of boosts!\n{{- else -}}\n   Your server doesn't have a lot of boosts yet :(\n{{- end }}\n"})}),"\n",(0,r.jsxs)(t.p,{children:["Notice the dash (",(0,r.jsx)(t.code,{children:"-"}),") inside each of the actions which is used to strip all whitespaces from that side."]})]})}function l(e={}){const{wrapper:t}={...(0,d.R)(),...e.components};return t?(0,r.jsx)(t,{...e,children:(0,r.jsx)(c,{...e})}):c(e)}},8843:(e,t,n)=>{n.d(t,{A:()=>s});const s=n.p+"assets/images/variables-button-3dac8c73707e2df422771ff06a19c658.png"}}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.