Skip to content

Commit f912a3c

Browse files
committed
docs: migrate member functions
Signed-off-by: Luca Zeuch <[email protected]>
1 parent 4e71ae9 commit f912a3c

File tree

1 file changed

+77
-12
lines changed

1 file changed

+77
-12
lines changed

content/docs/reference/templates/functions.md

Lines changed: 77 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -841,18 +841,83 @@ Subtracts the provided numbers from each other. Detects the first number's type
841841

842842
## Member
843843

844-
| **Function** | **Description** |
845-
| ------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
846-
| `getTargetPermissionsIn` memberID channelID | Returns target’s permissions in the given channel. |
847-
| `editNickname` "newNick" | Edits triggering user's nickname, argument has to be of type _string_. YAGPDB's highest role has to be above the highest role of the member and bot can't edit owner's nickname. |
848-
| `hasPermissions` arg | Returns true/false on whether triggering user has the permission bit _int64_ that is also set in .Permissions*.* |
849-
| `getMember` mention/userID | Function returns [Member object](/docs/reference/templates/syntax-and-data#member) having above methods. `{{(getMember .User.ID).JoinedAt}}` <br>is the same as `{{.Member.JoinedAt}}` |
850-
| `onlineCount` | Returns the count of online users/members on current server. |
851-
| `targetHasPermissions` memberID arg | Returns true/false on whether targeted member has the permission bit _int64_. |
852-
853-
Permissions are covered on
854-
[Discord permissions documentation](https://discord.com/developers/docs/topics/permissions#permissions-bitwise-permission-flags). For example to get
855-
permission bit for "use application commands" `{{bitwiseLeftShift 1 32}}` would return _int64_ `4294967296`.
844+
### editNickname
845+
846+
```yag
847+
{{ editNickname "newNick" }}
848+
```
849+
850+
Edits the nickname of the member who triggered the command. The bot must have the `MANAGE_NICKNAMES` permission and be
851+
higher in the role hierarchy than the member. The bot cannot change the nickname of the server owner.
852+
853+
### getMember
854+
855+
```yag
856+
{{ $member := getMember <mention|userID> }}
857+
```
858+
859+
Returns the [member object](/docs/reference/templates/syntax-and-data#member) for the given mention or user ID.
860+
861+
### getTargetPermissionsIn
862+
863+
```yag
864+
{{ $perms := getTargetPermissionsIn <memberID> <channelID> }}
865+
```
866+
867+
Returns the permissions of the specified member in the given channel as a [permissions bitfield][perms].
868+
869+
[perms]: https://discord.com/developers/docs/topics/permissions#permissions
870+
871+
#### Example
872+
873+
To calculate the permission in a channel other than the current channel, for which we could just use the
874+
[hasPermissions](#haspermissions) or [targetHasPermissions](#targethaspermissions) function, we will have to use bitwise
875+
operations:
876+
877+
```yag
878+
{{ $perms := getTargetPermissionsIn .User.ID $someChannel }}
879+
{{ $mask := bitwiseAnd .Permissions.ManageRoles $perms }}
880+
{{ if eq $mask .Permissions.ManageRoles }}
881+
You have the permissions to manage roles!
882+
{{ else }}
883+
You do not have the permissions to manage roles!
884+
{{ end }}
885+
```
886+
887+
### hasPermissions
888+
889+
```yag
890+
{{ $hasPerms := hasPermissions <permission> }}
891+
```
892+
893+
Returns whether the member who triggered the command has the specified permission bit.
894+
See [`.Permissions`](/docs/reference/templates/syntax-and-data/#context-data) for more information.
895+
896+
#### Example
897+
898+
```yag
899+
{{ if hasPermissions .Permissions.Administrator }}
900+
You have the Administrator permission!
901+
{{ else }}
902+
You do not have the Administrator permission.
903+
{{ end }}
904+
```
905+
906+
### onlineCount
907+
908+
```yag
909+
{{ $count := onlineCount }}
910+
```
911+
912+
Returns the count of online members on the current server, including bots.
913+
914+
### targetHasPermissions
915+
916+
```yag
917+
{{ $hasPerms := targetHasPermissions <memberID> <permission> }}
918+
```
919+
920+
Returns whether the specified member has the specified permission bit.
856921

857922
## Mentions
858923

0 commit comments

Comments
 (0)