sern-handler / handler

Create your dream Discord bot!
https://sern.dev
MIT License
38 stars 9 forks source link

feat: presence #345

Closed jacoobes closed 10 months ago

jacoobes commented 10 months ago

Declare a presence for sern to handle! The api is super simple. Ensure you have a file called presence.(file-ending) ADJACENT to wherever Sern.init is called! An example is here: ảnh Sern.init is called in index.ts. I make a file presence.ts next to it with this:

import { Presence } from '@sern/handler'

export default Presence.module({ 
    inject: ['@sern/client'],
    execute: (c) => {
        return Presence
            .of({ activities: [ { name: "deez nuts" } ] })
            .repeated(prev => { 
                return {
                    afk: true,
                    activities: prev.activities?.map(s => ({ ...s, name: s.name+"s" }))
                };
            }, 10000);
    }
})

The example demonstrates a repeating presence, where every 10 seconds, we re set the presence.