Closed catplvsplus closed 3 months ago
@setRecipleModule(supportedVersions?: string|string[])
@setRecipleModuleStart()
onStart
@setRecipleModuleLoad()
onLoad
@setRecipleModuleUnload()
onUnload
@setClientEvent(event: string, once?: boolean)
@setWebsocketEvent(event: string, once?: boolean)
@setRESTEvent(event: string, once?: boolean)
@setContextMenuCommand(data: ContextMenuCommandBuilder|ContextMenuCommandBuilderData)
@setMessageCommand(data: MessageCommandBuilder|MessageCommandBuilderData)
@setSlashCommand(data: SlashCommandBuilder|SlashCommandBuilderData)
import { setClientEvent, setContextMenuCommand, setMessageCommand, setRecipleModule, setRecipleModuleLoad, setRecipleModuleStart, setRecipleModuleUnload, setSlashCommand } from '@reciple/decorators'; import { AnyCommandExecuteData, CommandType, RecipleModuleData } from "reciple"; import { ApplicationCommandType, type Message } from 'discord.js'; @setRecipleModule() export class ExampleModule implements RecipleModuleData { /** * Executed when module is started (Bot is not logged in). */ @setRecipleModuleStart() async onStart(): Promise<boolean> { return true; } /** * Executes when the module is loaded (Bot is logged in). */ @setRecipleModuleLoad() async onLoad(): Promise<void> {} /** * Executes when the module is unloaded (Bot is pre log out). */ @setRecipleModuleUnload() async onUnload(): Promise<void> {} /** * Sets the commands */ @setContextMenuCommand({ name: 'ping', type: ApplicationCommandType.Message }) @setMessageCommand({ name: 'ping', description: 'Replies with pong!' }) @setSlashCommand({ name: 'ping', description: 'Replies with pong!' }) async handleCommandExecute(data: AnyCommandExecuteData): Promise<void> { switch (data.type) { case CommandType.ContextMenuCommand: case CommandType.SlashCommand: await data.interaction.reply('Pong!'); return; case CommandType.MessageCommand: await data.message.reply('Pong!'); return; } } @setClientEvent('messageCreate') async handleMessageEvent(message: Message): Promise<void> { if (!reciple.isReady() || (!message.content.includes(reciple.user.id) && !message.content.includes(reciple.user.displayName))) return; await message.react('👀'); } } export default new ExampleModule();
Added Decorators
Class Decorators
@setRecipleModule(supportedVersions?: string|string[])
Added to the module classMethod Decorators
@setRecipleModuleStart()
Added to theonStart
method of module classonStart
is executed@setRecipleModuleLoad()
Added to theonLoad
method of module classonLoad
is executed@setRecipleModuleUnload()
Added to theonUnload
method of module class@setClientEvent(event: string, once?: boolean)
Sets a module class method as a client event listener@setWebsocketEvent(event: string, once?: boolean)
Sets a module class method as a client.ws event listener@setRESTEvent(event: string, once?: boolean)
Sets a module class method as a client.rest event listener@setContextMenuCommand(data: ContextMenuCommandBuilder|ContextMenuCommandBuilderData)
Sets a module class method as a context menu execute@setMessageCommand(data: MessageCommandBuilder|MessageCommandBuilderData)
Sets a module class method as a message command execute@setSlashCommand(data: SlashCommandBuilder|SlashCommandBuilderData)
Sets a module class method as a slash command executeUsage