For Seyfert to work correctly, you need to update your tsconfig.json file and add emitDecoratorMetadata and experimentalDecorators to enable the use of decorators:
Seyfert supports two types of applications that interact with the Discord API: one based on the gateway (websocket) and another based on the HTTP interaction system.
Each type has a distinct purpose, and it is crucial to understand their differences to choose the one that best suits your needs. If you are unsure which bot type to choose, we recommend using the Gateway option.
The Gateway client handles all events emitted by Discord, such as messageCreate, interactionCreate, guildCreate, ready, among others.
The available events depend on the intents configured in the client.
Unlike the gateway, the HTTP client does not handle events.
Its functionality is limited to receiving interactions (commands and components) through HTTP requests sent from Discord.
Configuration
Once you have modified the tsconfig.json to support decorators, there are a few more steps before you can run your application. Seyfert is set up to automatically load your commands, events, components, and language.
For this, you need to create a file called seyfert.config.mjs in the root folder of your project and add the configuration according to the bot type you selected:
It is possible to modify this object, but such modifications will not be
reflected outside the Node.js process, or (unless explicitly requested)
to other Worker threads.
In other words, the following example would not work:
Assigning a property on process.env will implicitly convert the value
to a string. This behavior is deprecated. Future versions of Node.js may
throw an error when the value is not a string, number, or boolean.
import { env } from'node:process';
env.test=null;
console.log(env.test);
// => 'null'
env.test=undefined;
console.log(env.test);
// => 'undefined'
Use delete to delete a property from process.env.
import { env } from'node:process';
env.TEST=1;
deleteenv.TEST;
console.log(env.TEST);
// => undefined
On Windows operating systems, environment variables are case-insensitive.
import { env } from'node:process';
env.TEST=1;
console.log(env.test);
// => 1
Unless explicitly specified when creating a Worker instance,
each Worker thread has its own copy of process.env, based on its
parent thread's process.env, or whatever was specified as the env option
to the Worker constructor. Changes to process.env will not be visible
across Worker threads, and only the main thread can make changes that
are visible to the operating system or to native add-ons. On Windows, a copy of process.env on a Worker instance operates in a case-sensitive manner
unlike the main thread.
@param ― data - The runtime configuration data for http server.
@returns ― The internal runtime configuration for HTTP.
http({
token: string
token:
constBOT_TOKEN:string
BOT_TOKEN,
locations: Omit<RCLocations, "events">
locations: {
base: string
base:"dist", // replace with "src" if using bun
commands?:string
commands:"commands"
},
applicationId: string
applicationId:
constBOT_APP_ID:string
BOT_APP_ID,
port?:number
port:3000, // default is 8080
publicKey: string
publicKey:
constBOT_PUBLIC_KEY:string
BOT_PUBLIC_KEY,
});
This is not all, you also need to create a main file called index.ts inside the src folder (specified as base in the configuration) and start using it.