The following code snippets can be used in any TypeScript file in your project. However, it’s recommended to place a single declare module 'seyfert' in the main file src/index.ts that contains everything your bot needs.
Clients
Seyfert provides several client types to instantiate your bot, which could cause confusion when referencing the client in different parts of your code. To avoid this, you can specify the client type you’re using to TypeScript. Be sure to choose only one of the following three implementations:
Middlewares
To use your middlewares throughout the project, you need to inform TypeScript about their structure and composition. Export all middlewares from your code and provide them to Seyfert as follows:
// Assuming you exported all middlewares from './middlewares';
If you’re not yet familiar with middlewares, you can review their use cases and structure in their dedicated section.
Languages
To correctly configure types for languages, it’s recommended to establish a primary or base language that you always update. This way, all types will derive from this language, making it easier to keep the rest of the translations up to date.
// Assuming your base language is located in './langs/en';
Error ts(2741) ― Property 'onlyForAdmins' is missing in type '{}' but required in type 'ExtraProps'.
})
class
classTest
Testextends
classCommand
Command {}
declaremodule'seyfert' {
interface
interfaceExtraProps
ExtraProps {
ExtraProps.onlyForAdmins: boolean
onlyForAdmins:boolean;
ExtraProps.disabled?:true
disabled?:true;
ExtraProps.category?:string
category?:string
}
}
Internal Options
Since Seyfert supports various modes of operation, it’s necessary to add types as required by your implementations. For this, InternalOptions exists as an interface designed to include properties that transform Seyfert types into something more comprehensive.
declaremodule'seyfert' {
interface
interfaceInternalOptions
InternalOptions {
InternalOptions.withPrefix: true
withPrefix:true; // or false
InternalOptions.asyncCache: false
asyncCache:false; // or true
}
}
withPrefix
Setting this property to true tells Seyfert that the context can include either a message or an interaction, both of which will be optional. By default, .interaction is always present in the context.
asyncCache
Setting this property to true tells Seyfert whether the cache will return a promise. By default, Seyfert uses MemoryAdapter, a RAM cache that doesn’t return promises, while RedisAdapter does.
Configuration
In Seyfert, you can add more properties to the configuration file seyfert.config.mjs, regardless of whether you’re using the http or bot configuration. This can be done using ExtendedRC as follows:
declaremodule'seyfert' {
interface
interfaceExtendedRC
ExtendedRC {
ExtendedRC.developers: string[]
developers:string[];
// more properties here...
}
}
Locations
Just as you can extend Seyfert’s base configuration, you can also extend the folder locations object using ExtendedRCLocations. This can be done as follows: