chipmunkbot3/plugins/seen.js

28 lines
730 B
JavaScript
Raw Normal View History

2024-02-29 20:39:21 -05:00
function inject (bot) {
bot.on('player_data_loaded', (player, data) => {
data.data.seen ??= {}
const seenData = data.data.seen
2024-02-16 22:59:09 -05:00
if (seenData.first == null) {
seenData.first = createSeenValue()
bot.tellraw([
2024-04-02 17:53:10 -04:00
{ text: 'Welcome ', ...bot.styles.primary },
{ text: player.username, ...bot.styles.secondary },
2024-02-16 22:59:09 -05:00
' to the server!'
], '@a')
2024-02-16 22:59:09 -05:00
}
seenData.last = createSeenValue()
2024-02-16 22:59:09 -05:00
})
bot.on('player_data_unloading', (player, data) => {
const seenData = data.data.seen
if (seenData != null) seenData.last = createSeenValue()
2024-02-11 21:23:41 -05:00
})
function createSeenValue () {
return { date: new Date(), host: bot.host, port: bot.port ?? 25565 }
}
2024-02-11 21:23:41 -05:00
}
2024-02-29 20:39:21 -05:00
module.exports = inject