Readme
@syncopate/sdk
Section titled “@syncopate/sdk”Syncopate SDK — TypeScript
Build bots for Syncopate with a decorator-based API.
Example
Section titled “Example”import { Bot, OnEvent, Command, Message, Context } from '@syncopate/sdk';
class MyBot extends Bot { @OnEvent('ready') async onReady() { console.log(`Logged in as ${this.user.displayName}`); }
@OnEvent('messageCreate') async onMessage(message: Message) { if (message.author.bot) return; await message.channel.send('Hello!'); }
@Command('ping') async ping(ctx: Context) { await ctx.reply('Pong!'); }}
const bot = new MyBot({ token: 'bot_xxxx' });bot.run();Classes
Section titled “Classes”Defined in: sdk/typescript/src/client.ts:58
Main entry point for building Syncopate bots.
Subclass Bot and use @OnEvent() and @Command() decorators
to register event and command handlers.
Example
Section titled “Example”import { Bot, OnEvent, Command, Message, Context } from '@syncopate/sdk';
class MyBot extends Bot { @OnEvent('ready') async onReady() { console.log(`Logged in as ${this.user.displayName}`); }
@OnEvent('messageCreate') async onMessage(message: Message) { if (message.author?.bot) return; }
@Command('ping') async ping(ctx: Context) { await ctx.reply('Pong!'); }}
const bot = new MyBot({ token: 'bot_xxx' });bot.run();Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new Bot(
options):Bot
Defined in: sdk/typescript/src/client.ts:82
Parameters
Section titled “Parameters”options
Section titled “options”Returns
Section titled “Returns”Properties
Section titled “Properties”channels
Section titled “channels”
readonlychannels:Map<string,Channel>
Defined in: sdk/typescript/src/client.ts:69
Channel cache: id → Channel
commandPrefix
Section titled “commandPrefix”
readonlycommandPrefix:string
Defined in: sdk/typescript/src/client.ts:66
Command prefix (default: !).
readonlyrest:RestClient
Defined in: sdk/typescript/src/client.ts:63
REST client for API calls.
user:
User
Defined in: sdk/typescript/src/client.ts:60
The authenticated bot user. Available after ready event.
Methods
Section titled “Methods”disconnect()
Section titled “disconnect()”disconnect():
void
Defined in: sdk/typescript/src/client.ts:144
Disconnect the bot.
Returns
Section titled “Returns”void
fetchUser()
Section titled “fetchUser()”fetchUser(
userId):Promise<User>
Defined in: sdk/typescript/src/client.ts:158
Fetch a specific user by ID.
Parameters
Section titled “Parameters”userId
Section titled “userId”string
Returns
Section titled “Returns”Promise<User>
fetchWorkspaces()
Section titled “fetchWorkspaces()”fetchWorkspaces():
Promise<Workspace[]>
Defined in: sdk/typescript/src/client.ts:152
Fetch all workspaces the bot is a member of.
Returns
Section titled “Returns”Promise<Workspace[]>
getChannel()
Section titled “getChannel()”getChannel(
channelId):Promise<Channel>
Defined in: sdk/typescript/src/client.ts:164
Get a cached channel, or fetch it.
Parameters
Section titled “Parameters”channelId
Section titled “channelId”string
Returns
Section titled “Returns”Promise<Channel>
run():
Promise<void>
Defined in: sdk/typescript/src/client.ts:99
Start the bot: authenticate, cache channels, connect to SSE.
This method blocks until the bot is disconnected.
Returns
Section titled “Returns”Promise<void>
Channel
Section titled “Channel”Defined in: sdk/typescript/src/models/channel.ts:8
Model representing a Syncopate channel.
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new Channel(
data):Channel
Defined in: sdk/typescript/src/models/channel.ts:20
Parameters
Section titled “Parameters”ChannelData
Returns
Section titled “Returns”Properties
Section titled “Properties”_rest:
RestClient|null=null
Defined in: sdk/typescript/src/models/channel.ts:18
Internal
readonlyid:string
Defined in: sdk/typescript/src/models/channel.ts:9
insertedAt
Section titled “insertedAt”
readonlyinsertedAt:string
Defined in: sdk/typescript/src/models/channel.ts:14
readonlyname:string|null
Defined in: sdk/typescript/src/models/channel.ts:11
readonlytopic:string|null
Defined in: sdk/typescript/src/models/channel.ts:13
readonlytype:string
Defined in: sdk/typescript/src/models/channel.ts:12
updatedAt
Section titled “updatedAt”
readonlyupdatedAt:string
Defined in: sdk/typescript/src/models/channel.ts:15
workspaceId
Section titled “workspaceId”
readonlyworkspaceId:string
Defined in: sdk/typescript/src/models/channel.ts:10
Methods
Section titled “Methods”_bind()
Section titled “_bind()”_bind(
rest):this
Defined in: sdk/typescript/src/models/channel.ts:31
Internal
Inject the REST client for API calls.
Parameters
Section titled “Parameters”RestClient
Returns
Section titled “Returns”this
fetchMembers()
Section titled “fetchMembers()”fetchMembers():
Promise<ChannelMemberData[]>
Defined in: sdk/typescript/src/models/channel.ts:78
Fetch members of this channel.
Returns
Section titled “Returns”Promise<ChannelMemberData[]>
fetchMessages()
Section titled “fetchMessages()”fetchMessages(
options?):Promise<Message[]>
Defined in: sdk/typescript/src/models/channel.ts:60
Fetch messages from this channel.
Parameters
Section titled “Parameters”options?
Section titled “options?”afterSequence?
Section titled “afterSequence?”number
beforeSequence?
Section titled “beforeSequence?”number
limit?
Section titled “limit?”number
Returns
Section titled “Returns”Promise<Message[]>
fetchPresence()
Section titled “fetchPresence()”fetchPresence():
Promise<string[]>
Defined in: sdk/typescript/src/models/channel.ts:87
Fetch online user IDs in this channel.
Returns
Section titled “Returns”Promise<string[]>
send()
Section titled “send()”send(
content,options?):Promise<Message>
Defined in: sdk/typescript/src/models/channel.ts:37
Send a message to this channel.
Parameters
Section titled “Parameters”content
Section titled “content”string
options?
Section titled “options?”idempotencyKey?
Section titled “idempotencyKey?”string
parentId?
Section titled “parentId?”string
string
Returns
Section titled “Returns”Promise<Message>
toString()
Section titled “toString()”toString():
string
Defined in: sdk/typescript/src/models/channel.ts:109
Returns
Section titled “Returns”string
triggerTyping()
Section titled “triggerTyping()”triggerTyping():
Promise<void>
Defined in: sdk/typescript/src/models/channel.ts:96
Send a typing indicator.
Returns
Section titled “Returns”Promise<void>
ChannelMember
Section titled “ChannelMember”Defined in: sdk/typescript/src/models/member.ts:6
Model representing a channel member.
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new ChannelMember(
data):ChannelMember
Defined in: sdk/typescript/src/models/member.ts:14
Parameters
Section titled “Parameters”ChannelMemberData
Returns
Section titled “Returns”Properties
Section titled “Properties”channelId
Section titled “channelId”
readonlychannelId:string
Defined in: sdk/typescript/src/models/member.ts:8
readonlyid:string
Defined in: sdk/typescript/src/models/member.ts:7
insertedAt
Section titled “insertedAt”
readonlyinsertedAt:string
Defined in: sdk/typescript/src/models/member.ts:12
readonlyrole:string
Defined in: sdk/typescript/src/models/member.ts:10
readonlyuser:User
Defined in: sdk/typescript/src/models/member.ts:11
userId
Section titled “userId”
readonlyuserId:string
Defined in: sdk/typescript/src/models/member.ts:9
Context
Section titled “Context”Defined in: sdk/typescript/src/commands/context.ts:11
Command execution context.
Passed to @Command() handlers with the triggering message,
parsed arguments, and convenience methods for replying.
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new Context(
options):Context
Defined in: sdk/typescript/src/commands/context.ts:30
Parameters
Section titled “Parameters”options
Section titled “options”string[]
author
Section titled “author”channel
Section titled “channel”command
Section titled “command”string
message
Section titled “message”Returns
Section titled “Returns”Properties
Section titled “Properties”
readonlyargs:string[]
Defined in: sdk/typescript/src/commands/context.ts:25
Arguments after the command name, split by whitespace.
author
Section titled “author”
readonlyauthor:User
Defined in: sdk/typescript/src/commands/context.ts:19
The user who invoked the command.
channel
Section titled “channel”
readonlychannel:Channel
Defined in: sdk/typescript/src/commands/context.ts:16
The channel the command was invoked in.
command
Section titled “command”
readonlycommand:string
Defined in: sdk/typescript/src/commands/context.ts:22
The command name (without prefix).
content
Section titled “content”
readonlycontent:string
Defined in: sdk/typescript/src/commands/context.ts:28
The full raw content of the message.
message
Section titled “message”
readonlymessage:Message
Defined in: sdk/typescript/src/commands/context.ts:13
The message that triggered the command.
Methods
Section titled “Methods”reply()
Section titled “reply()”reply(
content):Promise<Message>
Defined in: sdk/typescript/src/commands/context.ts:51
Reply to the triggering message (threaded).
Parameters
Section titled “Parameters”content
Section titled “content”string
Returns
Section titled “Returns”Promise<Message>
send()
Section titled “send()”send(
content):Promise<Message>
Defined in: sdk/typescript/src/commands/context.ts:46
Send a message to the same channel.
Parameters
Section titled “Parameters”content
Section titled “content”string
Returns
Section titled “Returns”Promise<Message>
GatewayError
Section titled “GatewayError”Defined in: sdk/typescript/src/errors.ts:27
Raised when the SSE gateway connection fails.
Extends
Section titled “Extends”Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new GatewayError(
message):GatewayError
Defined in: sdk/typescript/src/errors.ts:28
Parameters
Section titled “Parameters”message
Section titled “message”string
Returns
Section titled “Returns”Overrides
Section titled “Overrides”Properties
Section titled “Properties”cause?
Section titled “cause?”
optionalcause:unknown
Defined in: web/node_modules/typescript/lib/lib.es2022.error.d.ts:26
Inherited from
Section titled “Inherited from”message
Section titled “message”message:
string
Defined in: web/node_modules/typescript/lib/lib.es5.d.ts:1077
Inherited from
Section titled “Inherited from”name:
string
Defined in: web/node_modules/typescript/lib/lib.es5.d.ts:1076
Inherited from
Section titled “Inherited from”stack?
Section titled “stack?”
optionalstack:string
Defined in: web/node_modules/typescript/lib/lib.es5.d.ts:1078
Inherited from
Section titled “Inherited from”HTTPError
Section titled “HTTPError”Defined in: sdk/typescript/src/errors.ts:14
Raised when an HTTP request fails.
Extends
Section titled “Extends”Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new HTTPError(
status,body,message?):HTTPError
Defined in: sdk/typescript/src/errors.ts:18
Parameters
Section titled “Parameters”status
Section titled “status”number
unknown
message?
Section titled “message?”string
Returns
Section titled “Returns”Overrides
Section titled “Overrides”Properties
Section titled “Properties”
readonlybody:unknown
Defined in: sdk/typescript/src/errors.ts:16
cause?
Section titled “cause?”
optionalcause:unknown
Defined in: web/node_modules/typescript/lib/lib.es2022.error.d.ts:26
Inherited from
Section titled “Inherited from”message
Section titled “message”message:
string
Defined in: web/node_modules/typescript/lib/lib.es5.d.ts:1077
Inherited from
Section titled “Inherited from”name:
string
Defined in: web/node_modules/typescript/lib/lib.es5.d.ts:1076
Inherited from
Section titled “Inherited from”stack?
Section titled “stack?”
optionalstack:string
Defined in: web/node_modules/typescript/lib/lib.es5.d.ts:1078
Inherited from
Section titled “Inherited from”status
Section titled “status”
readonlystatus:number
Defined in: sdk/typescript/src/errors.ts:15
Message
Section titled “Message”Defined in: sdk/typescript/src/models/message.ts:8
Model representing a Syncopate message.
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new Message(
data):Message
Defined in: sdk/typescript/src/models/message.ts:28
Parameters
Section titled “Parameters”MessageData
Returns
Section titled “Returns”Properties
Section titled “Properties”_rest:
RestClient|null=null
Defined in: sdk/typescript/src/models/message.ts:26
Internal
author
Section titled “author”author:
User|null=null
Defined in: sdk/typescript/src/models/message.ts:20
The author as a User object, if available from the event payload.
channel
Section titled “channel”channel:
Channel|null=null
Defined in: sdk/typescript/src/models/message.ts:23
The channel this message belongs to, if resolved.
channelId
Section titled “channelId”
readonlychannelId:string
Defined in: sdk/typescript/src/models/message.ts:10
content
Section titled “content”
readonlycontent:string
Defined in: sdk/typescript/src/models/message.ts:12
editedAt
Section titled “editedAt”
readonlyeditedAt:string|null
Defined in: sdk/typescript/src/models/message.ts:16
readonlyid:string
Defined in: sdk/typescript/src/models/message.ts:9
insertedAt
Section titled “insertedAt”
readonlyinsertedAt:string
Defined in: sdk/typescript/src/models/message.ts:17
parentId
Section titled “parentId”
readonlyparentId:string|null
Defined in: sdk/typescript/src/models/message.ts:15
sequence
Section titled “sequence”
readonlysequence:number
Defined in: sdk/typescript/src/models/message.ts:14
readonlytype:string
Defined in: sdk/typescript/src/models/message.ts:13
userId
Section titled “userId”
readonlyuserId:string
Defined in: sdk/typescript/src/models/message.ts:11
Methods
Section titled “Methods”_bind()
Section titled “_bind()”_bind(
rest):this
Defined in: sdk/typescript/src/models/message.ts:46
Internal
Inject the REST client.
Parameters
Section titled “Parameters”RestClient
Returns
Section titled “Returns”this
delete()
Section titled “delete()”delete():
Promise<void>
Defined in: sdk/typescript/src/models/message.ts:59
Delete this message.
Returns
Section titled “Returns”Promise<void>
edit()
Section titled “edit()”edit(
content):Promise<Message>
Defined in: sdk/typescript/src/models/message.ts:52
Edit this message.
Parameters
Section titled “Parameters”content
Section titled “content”string
Returns
Section titled “Returns”Promise<Message>
reply()
Section titled “reply()”reply(
content):Promise<Message>
Defined in: sdk/typescript/src/models/message.ts:65
Reply to this message (creates a threaded message).
Parameters
Section titled “Parameters”content
Section titled “content”string
Returns
Section titled “Returns”Promise<Message>
toString()
Section titled “toString()”toString():
string
Defined in: sdk/typescript/src/models/message.ts:80
Returns
Section titled “Returns”string
SyncopateError
Section titled “SyncopateError”Defined in: sdk/typescript/src/errors.ts:6
Base error for all SDK errors.
Extends
Section titled “Extends”Error
Extended by
Section titled “Extended by”Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new SyncopateError(
message):SyncopateError
Defined in: sdk/typescript/src/errors.ts:7
Parameters
Section titled “Parameters”message
Section titled “message”string
Returns
Section titled “Returns”Overrides
Section titled “Overrides”Error.constructor
Properties
Section titled “Properties”cause?
Section titled “cause?”
optionalcause:unknown
Defined in: web/node_modules/typescript/lib/lib.es2022.error.d.ts:26
Inherited from
Section titled “Inherited from”Error.cause
message
Section titled “message”message:
string
Defined in: web/node_modules/typescript/lib/lib.es5.d.ts:1077
Inherited from
Section titled “Inherited from”Error.message
name:
string
Defined in: web/node_modules/typescript/lib/lib.es5.d.ts:1076
Inherited from
Section titled “Inherited from”Error.name
stack?
Section titled “stack?”
optionalstack:string
Defined in: web/node_modules/typescript/lib/lib.es5.d.ts:1078
Inherited from
Section titled “Inherited from”Error.stack
Defined in: sdk/typescript/src/models/user.ts:4
Model representing a Syncopate user.
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new User(
data):User
Defined in: sdk/typescript/src/models/user.ts:10
Parameters
Section titled “Parameters”UserData
Returns
Section titled “Returns”Properties
Section titled “Properties”avatarUrl
Section titled “avatarUrl”
readonlyavatarUrl:string|null
Defined in: sdk/typescript/src/models/user.ts:7
readonlybot:boolean
Defined in: sdk/typescript/src/models/user.ts:8
displayName
Section titled “displayName”
readonlydisplayName:string|null
Defined in: sdk/typescript/src/models/user.ts:6
readonlyid:string
Defined in: sdk/typescript/src/models/user.ts:5
Accessors
Section titled “Accessors”Get Signature
Section titled “Get Signature”get isBot():
boolean
Defined in: sdk/typescript/src/models/user.ts:18
Whether this is a bot user.
Returns
Section titled “Returns”boolean
Methods
Section titled “Methods”toString()
Section titled “toString()”toString():
string
Defined in: sdk/typescript/src/models/user.ts:22
Returns
Section titled “Returns”string
Workspace
Section titled “Workspace”Defined in: sdk/typescript/src/models/workspace.ts:4
Model representing a Syncopate workspace.
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new Workspace(
data):Workspace
Defined in: sdk/typescript/src/models/workspace.ts:11
Parameters
Section titled “Parameters”WorkspaceData
Returns
Section titled “Returns”Properties
Section titled “Properties”
readonlyid:string
Defined in: sdk/typescript/src/models/workspace.ts:5
insertedAt
Section titled “insertedAt”
readonlyinsertedAt:string
Defined in: sdk/typescript/src/models/workspace.ts:8
readonlyname:string
Defined in: sdk/typescript/src/models/workspace.ts:6
readonlyslug:string
Defined in: sdk/typescript/src/models/workspace.ts:7
updatedAt
Section titled “updatedAt”
readonlyupdatedAt:string
Defined in: sdk/typescript/src/models/workspace.ts:9
Methods
Section titled “Methods”toString()
Section titled “toString()”toString():
string
Defined in: sdk/typescript/src/models/workspace.ts:19
Returns
Section titled “Returns”string
WorkspaceMember
Section titled “WorkspaceMember”Defined in: sdk/typescript/src/models/member.ts:37
Model representing a workspace member.
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new WorkspaceMember(
data):WorkspaceMember
Defined in: sdk/typescript/src/models/member.ts:44
Parameters
Section titled “Parameters”WorkspaceMemberData
Returns
Section titled “Returns”Properties
Section titled “Properties”
readonlyid:string
Defined in: sdk/typescript/src/models/member.ts:38
insertedAt
Section titled “insertedAt”
readonlyinsertedAt:string
Defined in: sdk/typescript/src/models/member.ts:42
readonlyrole:string
Defined in: sdk/typescript/src/models/member.ts:40
readonlyuser:User
Defined in: sdk/typescript/src/models/member.ts:41
userId
Section titled “userId”
readonlyuserId:string
Defined in: sdk/typescript/src/models/member.ts:39
Interfaces
Section titled “Interfaces”BotOptions
Section titled “BotOptions”Defined in: sdk/typescript/src/client.ts:16
Options for creating a Bot instance.
Properties
Section titled “Properties”baseUrl?
Section titled “baseUrl?”
optionalbaseUrl:string
Defined in: sdk/typescript/src/client.ts:21
Base URL of the Syncopate API. Defaults to http://localhost:4000.
commandPrefix?
Section titled “commandPrefix?”
optionalcommandPrefix:string
Defined in: sdk/typescript/src/client.ts:24
Command prefix. Defaults to !.
token:
string
Defined in: sdk/typescript/src/client.ts:18
The bot token (from Authorization: Bot <token>).
ChannelCreatedEvent
Section titled “ChannelCreatedEvent”Defined in: sdk/typescript/src/models/events.ts:60
Properties
Section titled “Properties”channelId
Section titled “channelId”channelId:
string
Defined in: sdk/typescript/src/models/events.ts:62
data:
object
Defined in: sdk/typescript/src/models/events.ts:63
id:
string
name:
string|null
topic:
string|null
type:
string
workspace_id
Section titled “workspace_id”workspace_id:
string
type:
"channelCreate"
Defined in: sdk/typescript/src/models/events.ts:61
ChannelDeletedEvent
Section titled “ChannelDeletedEvent”Defined in: sdk/typescript/src/models/events.ts:78
Properties
Section titled “Properties”channelId
Section titled “channelId”channelId:
string
Defined in: sdk/typescript/src/models/events.ts:80
data:
object
Defined in: sdk/typescript/src/models/events.ts:81
channel_id
Section titled “channel_id”channel_id:
string
type:
"channelDelete"
Defined in: sdk/typescript/src/models/events.ts:79
ChannelUpdatedEvent
Section titled “ChannelUpdatedEvent”Defined in: sdk/typescript/src/models/events.ts:72
Properties
Section titled “Properties”channelId
Section titled “channelId”channelId:
string
Defined in: sdk/typescript/src/models/events.ts:74
data:
object
Defined in: sdk/typescript/src/models/events.ts:75
optionalname:string
topic?
Section titled “topic?”
optionaltopic:string
optionaltype:string
type:
"channelUpdate"
Defined in: sdk/typescript/src/models/events.ts:73
MemberJoinedEvent
Section titled “MemberJoinedEvent”Defined in: sdk/typescript/src/models/events.ts:84
Properties
Section titled “Properties”channelId
Section titled “channelId”channelId:
string
Defined in: sdk/typescript/src/models/events.ts:86
data:
object
Defined in: sdk/typescript/src/models/events.ts:87
user_id
Section titled “user_id”user_id:
string
type:
"memberJoin"
Defined in: sdk/typescript/src/models/events.ts:85
MemberLeftEvent
Section titled “MemberLeftEvent”Defined in: sdk/typescript/src/models/events.ts:90
Properties
Section titled “Properties”channelId
Section titled “channelId”channelId:
string
Defined in: sdk/typescript/src/models/events.ts:92
data:
object
Defined in: sdk/typescript/src/models/events.ts:93
user_id
Section titled “user_id”user_id:
string
type:
"memberLeave"
Defined in: sdk/typescript/src/models/events.ts:91
MessageCreatedEvent
Section titled “MessageCreatedEvent”Defined in: sdk/typescript/src/models/events.ts:42
Properties
Section titled “Properties”channelId
Section titled “channelId”channelId:
string
Defined in: sdk/typescript/src/models/events.ts:44
data:
MessageData
Defined in: sdk/typescript/src/models/events.ts:45
type:
"messageCreate"
Defined in: sdk/typescript/src/models/events.ts:43
MessageDeletedEvent
Section titled “MessageDeletedEvent”Defined in: sdk/typescript/src/models/events.ts:54
Properties
Section titled “Properties”channelId
Section titled “channelId”channelId:
string
Defined in: sdk/typescript/src/models/events.ts:56
data:
object
Defined in: sdk/typescript/src/models/events.ts:57
message_id
Section titled “message_id”message_id:
string
type:
"messageDelete"
Defined in: sdk/typescript/src/models/events.ts:55
MessageUpdatedEvent
Section titled “MessageUpdatedEvent”Defined in: sdk/typescript/src/models/events.ts:48
Properties
Section titled “Properties”channelId
Section titled “channelId”channelId:
string
Defined in: sdk/typescript/src/models/events.ts:50
data:
MessageData
Defined in: sdk/typescript/src/models/events.ts:51
type:
"messageUpdate"
Defined in: sdk/typescript/src/models/events.ts:49
TypingStartEvent
Section titled “TypingStartEvent”Defined in: sdk/typescript/src/models/events.ts:96
Properties
Section titled “Properties”channelId
Section titled “channelId”channelId:
string
Defined in: sdk/typescript/src/models/events.ts:98
data:
object
Defined in: sdk/typescript/src/models/events.ts:99
user_id
Section titled “user_id”user_id:
string
type:
"typingStart"
Defined in: sdk/typescript/src/models/events.ts:97
Type Aliases
Section titled “Type Aliases”EventType
Section titled “EventType”EventType =
"ready"|"messageCreate"|"messageUpdate"|"messageDelete"|"channelCreate"|"channelUpdate"|"channelDelete"|"memberJoin"|"memberLeave"|"typingStart"
Defined in: sdk/typescript/src/models/events.ts:6
SSE event types emitted by the Syncopate backend.
SyncopateEvent
Section titled “SyncopateEvent”SyncopateEvent =
MessageCreatedEvent|MessageUpdatedEvent|MessageDeletedEvent|ChannelCreatedEvent|ChannelUpdatedEvent|ChannelDeletedEvent|MemberJoinedEvent|MemberLeftEvent|TypingStartEvent
Defined in: sdk/typescript/src/models/events.ts:103
Discriminated union of all event types.
Functions
Section titled “Functions”Command()
Section titled “Command()”Command(
name,options?): (target,propertyKey,_descriptor) =>void
Defined in: sdk/typescript/src/decorators/command.ts:34
Decorator that registers a method as a bot command handler.
Commands are triggered by messages matching the command prefix + name.
Default prefix is !.
Parameters
Section titled “Parameters”string
options?
Section titled “options?”description?
Section titled “description?”string
Returns
Section titled “Returns”(
target,propertyKey,_descriptor):void
Parameters
Section titled “Parameters”target
Section titled “target”unknown
propertyKey
Section titled “propertyKey”string
_descriptor
Section titled “_descriptor”PropertyDescriptor
Returns
Section titled “Returns”void
Example
Section titled “Example”class MyBot extends Bot { @Command('ping') async ping(ctx: Context) { await ctx.reply('Pong!'); }
@Command('greet', { description: 'Greet someone' }) async greet(ctx: Context) { const name = ctx.args[0] ?? 'world'; await ctx.reply(`Hello, ${name}!`); }}OnEvent()
Section titled “OnEvent()”OnEvent(
event): (target,propertyKey,_descriptor) =>void
Defined in: sdk/typescript/src/decorators/event.ts:31
Decorator that registers a method as an event handler.
Parameters
Section titled “Parameters”Returns
Section titled “Returns”(
target,propertyKey,_descriptor):void
Parameters
Section titled “Parameters”target
Section titled “target”unknown
propertyKey
Section titled “propertyKey”string
_descriptor
Section titled “_descriptor”PropertyDescriptor
Returns
Section titled “Returns”void
Example
Section titled “Example”class MyBot extends Bot { @OnEvent('messageCreate') async onMessage(message: Message) { // Handle message }
@OnEvent('ready') async onReady() { console.log('Bot is ready!'); }}