diff --git a/CHANGELOG.md b/CHANGELOG.md index 640d372..0fb3f87 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ The format is based on [keep a changelog](http://keepachangelog.com) and this pr - Add custom metrics publishing functions to Lua and JavaScript runtimes. - Add missing "sessionLogout" TypeScript definition. - Add "FriendsBlock" function to the runtimes. +- Add "ChannelMessagesList" function to the runtimes. ### Changed - Fix naming of delete notifications before/after hook registration functions. diff --git a/index.d.ts b/index.d.ts index c04b3d1..988f90e 100644 --- a/index.d.ts +++ b/index.d.ts @@ -4289,6 +4289,18 @@ declare namespace nkruntime { */ channelMessageUpdate(channelId: string, messageId: string, content?: {[key: string]: any}, senderId?: string, senderUsername?: string, persist?: boolean): ChannelMessageSendAck + /** + * List channel messages. + * + * @param channelId - Channel ID. + * @param limit - The number of messages to return per page. + * @param forward - Whether to list messages from oldest to newest, or newest to oldest. + * @param cursor - Opt. Pagination cursor. + * @returns List of channel messages. + * @throws {TypeError, GoError} + */ + channelMessagesList(channelId: string, limit?: number, forward?: boolean, cursor?: string): ChannelMessageList + /** * Send channel message. * diff --git a/runtime/runtime.go b/runtime/runtime.go index be816d2..362e536 100644 --- a/runtime/runtime.go +++ b/runtime/runtime.go @@ -1061,4 +1061,5 @@ type NakamaModule interface { ChannelIdBuild(ctx context.Context, sender string, target string, chanType ChannelType) (string, error) ChannelMessageSend(ctx context.Context, channelID string, content map[string]interface{}, senderId, senderUsername string, persist bool) (*rtapi.ChannelMessageAck, error) ChannelMessageUpdate(ctx context.Context, channelID, messageID string, content map[string]interface{}, senderId, senderUsername string, persist bool) (*rtapi.ChannelMessageAck, error) + ChannelMessagesList(ctx context.Context, channelId string, limit int, forward bool, cursor string) (messages []*api.ChannelMessage, nextCursor string, prevCursor string, err error) }