admin管理员组文章数量:1300110
I need to check if the account is new when interacting with the bot.
I was able to get information about the time the user joined the guild, but this information is not enough.
member.getJoinTime();
I tried to get the user object, but I didn't find any suitable methods.
I need to check if the account is new when interacting with the bot.
I was able to get information about the time the user joined the guild, but this information is not enough.
member.getJoinTime();
I tried to get the user object, but I didn't find any suitable methods.
Share Improve this question asked Feb 11 at 14:38 Евгений ШабарчинЕвгений Шабарчин 131 silver badge2 bronze badges2 Answers
Reset to default 2in discord every ID ( like for users, messages, etc.) has a unique number that stores the exact time it was created. in Discord4J, you can get that timestamp like this::
Member member = ...;
Snowflake id = member.getId();
Instant creationTime = id.getTimestamp();
OffsetDateTime readableTime = creationTime.atOffset(ZoneOffset.UTC);
Done! This will show you when the user's account was created,
like: 2023-10-01T12:34:56Z.
Discord uses snowflakes for IDs that contain information about the timestamp meaning the timestamp of the ID can be extracted from anything that has an ID.
In Discord4j, you can use User#getId
to get the ID from the member as a Snowflake
object. You can then use the Snowflake#getTimestamp
method to convert it to an Instant
representing the timestamp.
Member member = ...;
Instant accountCreationTimestamp = member.getId().getTimestamp();
OffsetDateTime accountCreationDateTime = accountCreationTimestamp.atOffset(ZoneOffset.UTC);
本文标签: javaHow to get member account creation dateStack Overflow
版权声明:本文标题:java - How to get member account creation date? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741656504a2390789.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论