How to save and display a user's registration date in a bot
In this tutorial, we'll explore one possible approach to recording your users' registration dates. This method is ideal for investment, gaming, referral, and airdrop bots.
❖ Why you shouldn't save the date when pressing START
Many people ask how to record a user's registration date immediately, the first time they click /start command in a bot. Bots created with the @MenuBuilderBot constructor getting MILLIONS of new users EVERY MONTH. A huge percentage of these users, who launch yet another bot out of curiosity, close it within the first minute and never return, essentially becoming «dead weight». We don't need their data, and it is useless for the actual bot's creator as well. For this reason, the constructor doesn't store any data about accounts that simply launch a bot. Therefore, this data is unavailable to you, as an admin.
For analytics, referral payments, and airdrop coin distribution, only those people who are genuinely interested in your project are important. Therefore, it's best to record their registration (joining) date only when the user actually performs the first key action - for example, successfully passes the channel Subscription verification, fills out the Feedback Form, or clicks the «Complete Task» button. This confirms that this is a real, active bot user. Therefore, we suggest implementing the registration date recording mechanism in a specific location, rather than for everyone.
❖ Acquisition of functionality
All functionality is acquired IN YOUR BOT, for this go to your bot:☞ 🔐Admin | 🧩Extensions
IMPORTANT: The purchase of functionality for the bot is available only to the Creator (owner) of the bot. Admins CANNOT buy functionality!
You will need:
1. Variable - 1 piece☞ 🔐Admin | 🧩Extensions | 📂Variables
2. Actions - 1 piece☞ 🔐Admin | 🧩Extensions | 📂Actions
4. Plugin - Macros and Expressions for Buttons☞ 🔐Admin | 🧩Extensions | 📂Buttons
Guide for «Variables»
Guide for «Actions»
Guide for «Expressions»
❖ Creation of date saving functionality
Step 1: Create a «Date and Time» Variable
To store the date, we need a special Variable of «Date and Time» type.
1. Go to the variable editor: ☞ 🔐Admin | 🗄Variables | 📕Time
2. Click the button «➕ Create Variable».
3. Enter the variable name in Latin characters. For example: reg_date (registration date).
Step 2: Bind the «action of initialization» to the button
Let's set up a key action button so that when it is pressed, the bot uses the Action to record the current time.
We assume that you have already created the functional button itself and that the overall design of your project is already fundamentally ready.
1. Go to the «Buttons Editor» in your bot's menu.
2. Click the button that confirms user activity in your project (e.g. «Check Subscription», «Get Bonus», or «Complete Task»). This will place the editor's selection on that button.
3. In the button's data message that appears, click the settings button with the asterisk ("*️⃣").
4. Select «Set Pre-Action» (to perform the action BEFORE the button message is shown).
5. Select: «Action of Initialization».
6. Follow the step-by-step setup wizard:
- Specify the variable: select the variable you created earlier reg_date.
- Specify the value: send the bot an Expression with the current time function: {dt_now()}.
7. Optionally, you can set the messages about success or leave it empty by clicking «Set Empty».
The «Action of Initialization» (instead of the standard «Action of Numbers») is convenient because it doesn't require a separate Condition to validate the data. It will only run once: the initialization action is triggered only when the variable is completely empty (not initialized). In this case, the variable reg_date is filled with the current time. All subsequent clicks of the same button (for example, when the user claims a daily bonus or checks their status) will ignore the initialization action because the variable has already been initialized!
Step 3. Displaying the registration date to the user and using it in the project logic
1. Displaying the date in the user profile (Personal Account)
You can display the saved registration date in any bot message (for example, in «My Profile» button) using a Variable Macros:
Example Message:
"👤 YOUR PROFILE
💵 Balance: %balance% coins
📅 Registration date: %reg_date%"
You can derive values from this date (for example, how many days have passed since registration) - see the Guide «Working with Date and Time».
2. Displaying the registration date taking into account the bot's time zone
The function {dt_now()} returns the server's system time (UTC+3).
If you have a different time zone, you can display the date taking it into account using the Expression:{dt_add("%reg_date%", 1)}
(Where 1 is +1 hour difference from your time zone. Use negative values (-1, -2 etc.) if your time zone is UTC+2 or less.)
3. Data export
When an airdrop or referral contest ends, you can easily export a list of all verified users along with their registration dates in an Excel spreadsheet (.csv) using the command:/varexp - to export all data
or/varexp reg_date - to export only the registration dates. The bot will send you a file containing only the IDs of active users and the exact time they registered their participation.
See Guide: «Export of User Data».