Recipes

Transformers

What is a transformer?

Basically, a transformer is a function that takes an object and transforms it into another value. In Seyfert, transformers are used to transform data coming from Discord into any values you need.

How are they used?

Let's look at an example of a transformer.

import {  } from 'seyfert';
 
. = (, ) => {
    return {
        : .,
        : .() > 0.5,
        () {
            return ..(.);
        },
    };
};
 
/*
At this point, you should have a `declare module "seyfert"` in your project, 
if not, add it.
*/
declare module "seyfert" {
// Declaring the type this way will reflect in the typing throughout the entire project.
    interface CustomStructures {
        : MyUser;
    }
// You can add as many transformers as you like with any type.
}

Let the autocomplete of your editor guide you and discover all the possibilities you have.

import {  } from 'seyfert';
 
.Guil
  • Guild
  • GuildBan
  • GuildEmoji
  • GuildMember
  • GuildRole
  • GuildTemplate

How can I use them?

For example, we defined a transformer for the user earlier, now let's see how we can use it.

import { type , ,  } from 'seyfert';
 
@({
    : 'ping',
    : 'Ping!',
})
class  extends  {
    async (: ) {
        const  = await ..
  • isAdmin
  • raw
  • username
();
.(., .); } }

On this page