Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import { ActivityType, Client } from "discord.js";
- import addPoints from "../utils/addPoints.js"; // util used to add points to the numbers
- import cron from "node-cron";
- import { getBotd } from "../utils/getBOTD.js"; // Bestemmia of the day, basically it's "blasphemy of the day" but in italian
- export const name = 'ready';
- export const once = true;
- export async function execute(client: Client<true>) {
- console.log('ready');
- await client.database.connect();
- let bestemmieDocs = await client.dbCollections.bestemmie.find({ globalbestemmie: undefined }).toArray();
- let numeroBestemmie = 0;
- for (let bestemmieDoc of bestemmieDocs) {
- numeroBestemmie += bestemmieDoc.bestemmieGlobal;
- }
- if (client.user.username.endsWith('Staging')) {
- client.prefix = '..';
- }
- if (client.manutenzione) {
- client.user.setActivity(`🔴🛠️ MANUTENZIONE IN CORSO`, { type: ActivityType.Watching }); // maintenance mode
- return;
- }
- client.user.setActivity(`${addPoints(numeroBestemmie)} bestemmie totali.`, { type: ActivityType.Watching });
- // we disabled this to check if it was the issue, but it still dies after a while
- /* setInterval(async () => {
- bestemmieDocs = await client.dbCollections.bestemmie.find({ globalbestemmie: undefined }).toArray();
- numeroBestemmie = 0;
- for (let bestemmieDoc of bestemmieDocs) {
- numeroBestemmie += bestemmieDoc.bestemmieGlobal;
- }
- client.user.setActivity(`${addPoints(numeroBestemmie)} bestemmie totali.`, { type: ActivityType.Watching });
- }, 1 * 60 * 60 * 1000);
- */
- cron.schedule('0 0 23 * * *', async () => { //botd
- const botd = await getBotd(client);
- let embed = {
- title: 'Bestemmia del giorno',
- description: botd
- }
- // @ts-ignore
- await (await client.channels.fetch("1059884162909212765")).send({ embeds: [embed] }) // sends botd to the channel in our server
- });
- }
Advertisement
Add Comment
Please, Sign In to add comment