chipmunkbot3/plugins/seen.js

23 lines
598 B
JavaScript

function inject (bot) {
bot.on('player_data_loaded', (player, data) => {
data.data.seen ??= {}
const seenData = data.data.seen
if (seenData.first == null) {
seenData.first = new Date()
bot.tellraw([
{ text: 'Welcome ', ...bot.styles.primary },
{ text: player.username, ...bot.styles.secondary },
' to the server!'
], '@a')
}
seenData.last = new Date()
})
bot.on('player_data_unloading', (player, data) => {
const seenData = data.data.seen
if (seenData != null) seenData.last = new Date()
})
}
module.exports = inject