Saltearse al contenido
sern

Presence

const Presence: object

Type declaration

module()

module: <T>(conf) => Config<T>

A small wrapper to provide type inference. Create a Presence module which MUST be put in a file called presence.(language-extension) adjacent to the file where Sern.init is CALLED.

Type parameters

T extends keyof Dependencies[]

Parameters

conf: Config<T>

Returns

Config<T>

of()

of: (root) => object

Create a Presence body which can be either:

  • once, the presence is activated only once.
  • repeated, per cycle or event, the presence can be changed.

Parameters

root: Omit<Result, "repeat" | "onRepeat">

Returns

object

once()

once: () => Omit<Result, "repeat" | "onRepeat">

Example
1
Presence.of({
2
activities: [{ name: "Chilling out" }]
3
}).once() // Sets the presence once, with what's provided in '.of()'
Returns

Omit<Result, "repeat" | "onRepeat">

repeated()

repeated: (onRepeat, repeat) => object

Example
1
Presence
2
.of({ activities: [{ name: "deez nuts" }] }) //starts presence with "deez nuts".
3
.repeated(prev => {
4
return {
5
afk: true,
6
activities: prev.activities?.map(s => ({ ...s, name: s.name+"s" }))
7
};
8
}, 10000)) //every 10 s, the callback sets the presence to the value returned.
Parameters

onRepeat: PresenceReduce

repeat: number | [Emitter, string]

Returns

object

activities?

optional activities: ActivitiesOptions[]

afk?

optional afk: boolean

onRepeat

onRepeat: PresenceReduce

repeat

repeat: number | [Emitter, string]

shardId?

optional shardId: number[]

status?

optional status: Status

Source

src/core/presences.ts:10