mirror of
https://github.com/SrIzan10/sern-community.git
synced 2026-05-01 11:05:19 +00:00
28 lines
998 B
TypeScript
28 lines
998 B
TypeScript
import { ActivityType, Client, ClientPresenceStatus } from "discord.js";
|
|
|
|
const statues: [Exclude<ActivityType, ActivityType.Custom>, string, ClientPresenceStatus][] = [
|
|
[ActivityType.Watching, "the sern community", "online"],
|
|
[ActivityType.Listening, "Evo", "dnd"],
|
|
[ActivityType.Playing, "with @sern/cli", "idle"],
|
|
[ActivityType.Watching, "sern bots", "dnd"],
|
|
[ActivityType.Watching, "github stars go brrr", "online"],
|
|
[ActivityType.Listening, "Spotify", "dnd"],
|
|
[ActivityType.Listening, "what's bofa", "idle"],
|
|
];
|
|
|
|
export function randomStatus(client: Client) {
|
|
setInterval(() => {
|
|
const shuffledStatuses = shuffleArray(statues);
|
|
const [type, name, status] = [...shuffledStatuses].shift()!;
|
|
client.user!.setPresence({ activities: [{ name, type }], status });
|
|
}, 60_000);
|
|
}
|
|
|
|
function shuffleArray<T>(array: T[]) {
|
|
for (let i = array.length - 1; i > 0; i--) {
|
|
const j = Math.floor(Math.random() * (i + 1));
|
|
[array[i], array[j]] = [array[j], array[i]];
|
|
}
|
|
return [...array];
|
|
}
|