2023-04-05 17:47:02 +02:00
|
|
|
import { ActivityType } from 'discord.js';
|
2022-08-15 15:14:25 +02:00
|
|
|
import game from '../../json/playing.json' assert {type: 'json'};
|
2023-06-04 19:02:44 +02:00
|
|
|
import music from '../../json/listening.json' assert {type: 'json'};
|
2022-08-15 15:14:25 +02:00
|
|
|
import watch from '../../json/watching.json' assert {type: 'json'};
|
|
|
|
|
|
|
|
export default {
|
|
|
|
name: 'ready',
|
|
|
|
once: true,
|
|
|
|
async execute(client) {
|
|
|
|
// Bot status
|
2023-04-05 17:47:02 +02:00
|
|
|
await setStatus();
|
2022-08-15 15:14:25 +02:00
|
|
|
// Change status every 30 minutes
|
|
|
|
setInterval(async () => {
|
2023-04-05 17:47:02 +02:00
|
|
|
await setStatus();
|
2022-08-15 15:14:25 +02:00
|
|
|
}, 1800000);
|
|
|
|
|
|
|
|
async function setStatus() {
|
2023-06-04 19:02:44 +02:00
|
|
|
const random = Math.floor((Math.random() * 3));
|
2023-04-05 17:47:02 +02:00
|
|
|
let types, status;
|
2022-08-15 15:14:25 +02:00
|
|
|
// Random "Watching" status taken from json
|
|
|
|
if (random === 0) {
|
|
|
|
console.log('Status type: \x1b[32mWatching\x1b[0m');
|
|
|
|
|
2023-04-05 17:47:02 +02:00
|
|
|
status = watch[Math.floor((Math.random() * watch.length))];
|
2022-08-16 21:12:49 +02:00
|
|
|
status = status + ' | Now with slash commands!';
|
2022-08-15 15:14:25 +02:00
|
|
|
console.log(`Setting status to: ${status}`);
|
2023-04-05 17:47:02 +02:00
|
|
|
types = [ ActivityType.Watching ];
|
2022-08-15 15:14:25 +02:00
|
|
|
}
|
|
|
|
// Random "Playing" status taken from json
|
|
|
|
else if (random === 1) {
|
|
|
|
console.log('Status type: \x1b[32mPlaying\x1b[0m');
|
|
|
|
|
2023-04-05 17:47:02 +02:00
|
|
|
status = game[Math.floor((Math.random() * game.length))];
|
2022-08-16 21:12:49 +02:00
|
|
|
status = status + ' | Now with slash commands!';
|
|
|
|
|
2022-08-15 15:14:25 +02:00
|
|
|
console.log(`Setting status to: ${status}`);
|
2023-04-05 17:47:02 +02:00
|
|
|
types = [ ActivityType.Playing, ActivityType.Competing ];
|
2022-08-15 15:14:25 +02:00
|
|
|
}
|
2023-06-04 19:02:44 +02:00
|
|
|
else if (random === 2) {
|
|
|
|
console.log('Status type: \x1b[32mPlaying\x1b[0m');
|
|
|
|
|
|
|
|
status = music[Math.floor((Math.random() * music.length))];
|
|
|
|
status = status + ' | Now with slash commands!';
|
|
|
|
|
|
|
|
console.log(`Setting status to: ${status}`);
|
|
|
|
types = [ ActivityType.Listening ];
|
|
|
|
}
|
2023-04-05 17:47:02 +02:00
|
|
|
await client.user.setActivity(status, { type: types[Math.floor((Math.random() * types.length))] });
|
2022-08-15 15:14:25 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
};
|