Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- I'm using ENMAP btw for the weekly joins
- {
- CronJob
- } = require('cron'),
- Enmap = require('enmap')
- client.join = new Enmap({name: "joins", autoFetch: true, fetchAll: true})
- const job = new CronJob('0 12 * * Sun', () => {
- client.joins.clear()
- }, null, true, 'America/Los_Angeles')
- Index.js file ^^
- guildMemberAdd event
- client.joins.ensure(member.guild.id, {
- "monday": 0,
- "tuesday": 0,
- "wednesday": 0,
- "thursday": 0,
- "friday": 0,
- "saturday": 0,
- "sunday": 0,
- })
- let days = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'];
- let dayName = days[new Date().getDay()].toLowerCase()
- client.joins.inc(member.guild.id, dayName)
- Command file.js
- const guildJoins = client.joins.ensure(message.guild.id, {
- "monday": 0,
- "tuesday": 0,
- "wednesday": 0,
- "thursday": 0,
- "friday": 0,
- "saturday": 0,
- "sunday": 0,
- })
- const chart = {
- type: 'line',
- data: {
- labels: ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'],
- datasets: [{
- label: 'Joins',
- data: Object.values(guildJoins)
- }]
- }
- }
- let enChart = encodeURIComponent(JSON.stringify(chart))
- const chartUrl = `https://quickchart.io/chart?c=${enChart}&backgroundColor=(rgb(47,%2049,%2054))`;
- message.channel.send(new Discord.MessageAttachment(chartUrl, "chart.png"))
Advertisement
Add Comment
Please, Sign In to add comment