Entity Info
nickname
$nickname
The function $nickname returns the nickname of a user on the current server. If the user has no nickname it does not return an empty string: it returns the user’s display name (global name, or the username if there is none).
Syntax
$nickname[(userID)]
Parameters
| Parameter | Description |
|---|---|
userID |
(Optional) The ID of the user. Default: the author of the command. A value that is not a positive integer raises Invalid user ID. |
Return Value
- Type : String
- The server nickname if set, otherwise the display name (global name, else username) fetched from Discord.
- The error
User is not a member of this guild.is raised if the user is not a member of the current server, andUser not found.if Discord does not know the user.
Behavior
- The member is always fetched from Discord; the function does not read a context variable (unlike
$memberNick). - Because of the fallback,
$nicknamecannot be used to detect whether a nickname is set.
Examples
Greeting with the nickname
$sendMessage[Hello $nickname! (username: $userName)]
Displaying name details
$title[Names of $userName]
$description[
**Global Username:** $userName
**Server Nickname:** $nickname
**Display Name:** $displayName
]
$color[#5865F2]
Notes
$displayNamereturns the global name (or the username) of a user and works for users who are not members of the server.$memberNickis a different function: without argument it reads host-supplied context variables first (see its page).
Try it
Paste an example into the playground to preview its message (functions that act on Discord are not run), or build the same thing with blocks.