sets afk status and reports where you were mentioned while you were afk

This two-part AFK system combines an /afk slash command with an automated message_create event listener to manage user availability, server nicknames, and missed-ping logs using two persistent variables. The first variable (wzju3dw7f21ushys) stores a user's active AFK stateβholding their departure Unix timestamp, user ID, and optional status reasonβwhile the second variable (e24lu0zavsqgjrgs) acts as a dedicated log that counts and formats every mention or reply the user receives while away. By scoping both variables to the user's ID, the flow keeps state lookups consistent from the moment a member goes AFK until they return to chat.
When a member runs the /afk command, the flow captures their optional reason (up to 200 characters) and writes their current Unix timestamp and reason into the AFK status variable. It immediately resets their mention history variable back to a count of zero and empty lines so old pings from previous sessions never carry over, then sends a confirmation response in the channel. Right after responding, the flow checks whether adding an [AFK] prefix to the user's current display name or nickname keeps the total length within Discord's 32-character limit; if valid, it updates their nickname inside an error handler block so the bot gracefully skips the edit instead of failing when a user has a higher role or owns the server.
While the user is away, the message_create listener runs two parallel checks on every incoming message, handling mention and reply detection on its right branch. The listener scans the message's mention list for any non-bot user other than the message author, which automatically catches both direct user tags and Discord message replies when the reply ping is turned on. If a mentioned user is detected, the flow queries their AFK status variable to verify whether they have an active timestamp, stopping cleanly if the user is not currently AFK.
When a mentioned or replied-to user is confirmed to be AFK, the listener updates their mention history before notifying the channel. It retrieves the target user's existing history data, increments their total mention count by one, and appends a new formatted entry containing the sender's mention, the channel link, a live relative Discord timestamp, and a clickable Jump hyperlink pointing directly to the message URL. Once the updated log is saved, the bot replies directly to the triggering message to let the sender know how long ago the user went AFK and display their custom reason.
The left branch of the message_create listener handles the automatic return sequence the moment an AFK user sends a new message. When the flow detects an active AFK timestamp for the message author, it deletes their AFK status variable and triggers two actions simultaneously: stripping the [AFK] prefix from their server nickname (wrapped in an error handler for permission safety) and retrieving their saved mention history. Finally, the bot replies to the returning user with a combined welcome-back embed that shows when they originally went AFK alongside the full count and jump links for every mention they missed while away, before resetting their mention history variable clean.
Open one to see its blocks and what it costs.
Create your bot in Kite for free, then add Set AFK from the Marketplace in your app and change anything you like in the editor.
Get started
Kite
Kite
Add templates or build commands with blocks and AI. Free to start, hosted 24/7.