Skip to content

Commit

Permalink
Add joined_at time to discord_member_info()
Browse files Browse the repository at this point in the history
  • Loading branch information
PseudoKnight committed Feb 6, 2024
1 parent 3d3e413 commit eab16b1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ Requires the `Manage Channels` permission.
Gets an array of data for Discord user.
Array contains 'userid', 'username', 'displayname', and 'bot' (boolean).
For this guild server it also contains:
'nickname' (empty if not set), 'color' array (null if none), and 'avatar' effective url.
'nickname' (empty if not set), 'color' array (null if none), 'joined_at' timestamp, and 'avatar' effective url.

### discord_member_get_roles([server], member)
Gets an associative array of all guild server roles for a member.
Expand Down
5 changes: 4 additions & 1 deletion src/main/java/me/pseudoknight/chdiscord/MemberFunctions.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import net.dv8tion.jda.api.utils.messages.MessageCreateData;

import java.awt.Color;
import java.time.Instant;

public class MemberFunctions {
public static String docs() {
Expand Down Expand Up @@ -307,7 +308,8 @@ public String docs() {
return "array {[server], member} Gets an array of data for Discord user."
+ GuildFunctions.SERVER_ARGUMENT
+ " Array contains 'userid', 'username', 'displayname', and 'bot' (boolean). For this guild server"
+ " it also contains: 'nickname' (empty if not set), 'color' array (null if none), and 'avatar' effective url.";
+ " it also contains: 'nickname' (empty if not set), 'color' array (null if none),"
+ " 'joined_at' timestamp, and 'avatar' effective url.";
}

public Integer[] numArgs() {
Expand Down Expand Up @@ -336,6 +338,7 @@ public Mixed exec(Target t, Environment environment, Mixed... args) throws Confi
ret.set("color", CNull.NULL, t);
}
ret.set("avatar", member.getEffectiveAvatarUrl());
ret.set("joined_at", new CInt(Instant.from(member.getTimeJoined()).toEpochMilli(), t), t);

User user = member.getUser();
ret.set("userid", new CInt(user.getIdLong(), t), t);
Expand Down

0 comments on commit eab16b1

Please sign in to comment.