Watches your Discord presence over the Lanyard websocket and writes a lastseen timestamp to your Lanyard KV store whenever you go offline.
- Node.js 18 or newer
- A Lanyard API key: join the Lanyard Discord server, then DM
Lanyard#5766and send.apikeyto get it - Your Discord user ID with the Lanyard bot present in a shared server (Lanyard only tracks presence for users in a server it's in)
git clone https://github.com/sleepingcat1714/lanylastseen
cd lanylastseen
npm installCreate a .env file in the folder:
user_id=
token=
ws_url=wss://api.lanyard.rest/socket
kv_key=lastseen
time_format=0
discord_timestamp_style=6
All of these must be set.
user_id- your Discord user IDtoken- your Lanyard API tokenws_url- Lanyard websocket URL (change if self-hosting Lanyard)kv_key- KV key to write the timestamp totime_format/discord_timestamp_style- see Timestamp format below
Then:
npm startThe time_format is how the lastseen value gets written:
time_format |
Format |
|---|---|
0 |
Epoch milliseconds (default) |
1 |
Epoch seconds |
2 |
ISO 8601 |
3 |
Discord timestamp markdown (<t:seconds:style>) |
4 |
Readable plain text |
When time_format=3, discord_timestamp_style picks the Discord markdown style:
discord_timestamp_style |
Style | Example |
|---|---|---|
0 |
t short time |
16:20 |
1 |
T long time |
16:20:30 |
2 |
d short date |
20/04/2026 |
3 |
D long date |
20 April 2026 |
4 |
f short date/time |
20 April 2026 16:20 |
5 |
F long date/time |
Tuesday, 20 April 2026 16:20 |
6 |
R relative (default) |
5 minutes ago |
Install Docker first, then:
docker build -t lanylastseen .
docker run -d --name lanylastseen --env-file .env --restart unless-stopped lanylastseenIf you'd like to run with docker-compose, use this:
services:
lanylastseen:
build: .
container_name: lanylastseen
env_file: .env
restart: unless-stoppedand start it
docker compose up -dMIT see LICENSE.