Bu içerik henüz dilinizde mevcut değil.
Your bot should have a personality. (or invite link)
Your presence will be set once, after discord.js Client is called.
Client
1import { Presence } from '@sern/handler'2import { ActivityType } from 'discord.js';3 4const activity = { type: ActivityType.Listening, name: "what's bofa" };5 6export default Presence.module({7 execute: () => {8 return Presence9 .of({ activities: [activity], status: "idle" })10 .once();11 }12 })
Set your presence on intervals or events emitted. An example of this is shuffling presences on intervals.
1import { Presence } from '@sern/handler'2import { ActivityType, ClientPresenceStatus } from 'discord.js';3 4/**5 * Sorry for using any[]6 * @param array {any[]}7 */8function shuffleArray(array) {9 for (let i = array.length - 1; i > 0; i--) {10 const j = Math.floor(Math.random() * (i + 1));11 [array[i], array[j]] = [array[j], array[i]];12 }13 return [...array];14}15 16const statuses = [[ActivityType.Watching, "the sern community", "online"],17 [ActivityType.Listening, "Evo", "dnd"],18 [ActivityType.Playing, "with @sern/cli", "idle"],19 [ActivityType.Watching, "sern bots", "dnd"],20 [ActivityType.Watching, "github stars go brrr", "online"],21 [ActivityType.Listening, "what's bofa", "idle"]];22 23export default Presence.module({24 execute: () => {25 const [type, name, status] = statuses.at(0)!;26 return Presence27 //start your presence with this.28 .of({ activities: [ { type, name } ], status })29 .repeated(() => {30 const [type, name, status] = [...shuffleArray(statuses)].shift()!;31 return {32 status,33 activities: [{ type, name }]34 };35 }, 60_000); //repeat and setPresence with returned result every minute36 }37})
1import { Presence } from '@sern/handler'2import { ActivityType } from 'discord.js';3 4const activity = { type: ActivityType.Listening, name: "what's bofa" };5export default Presence.module({6 inject: ['@sern/logger'],7 execute: (logger) => {8 logger?.info({ message: "Presence changed" });9 return Presence10 .of({ activities: [activity], status: "idle" })11 .once();12 }13 })