From b1d00889bc0ca169bd8a4da937b06fbf46bea7bb Mon Sep 17 00:00:00 2001 From: Paul Date: Wed, 23 Jun 2021 13:36:05 +0100 Subject: [PATCH] API: Add support for voice channels. API: Add support for replies. --- package.json | 2 +- src/api/objects.ts | 18 +++++++++++++----- src/api/permissions.ts | 4 +++- src/api/routes.ts | 8 +++++--- 4 files changed, 22 insertions(+), 10 deletions(-) diff --git a/package.json b/package.json index 3227def5..3c72e785 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "revolt.js", - "version": "4.3.1-alpha.0", + "version": "4.3.2", "main": "dist/index.js", "repository": "https://gitlab.insrt.uk/revolt/revolt.js", "author": "Paul Makles ", diff --git a/src/api/objects.ts b/src/api/objects.ts index 699914dd..7048b87d 100644 --- a/src/api/objects.ts +++ b/src/api/objects.ts @@ -175,18 +175,25 @@ export namespace Channels { icon?: Attachment } - export type TextChannel = { + export type ServerChannel = { _id: string, - channel_type: 'TextChannel', server: string, name: string, description: string, - icon?: Attachment, + icon?: Attachment + } + + export type TextChannel = ServerChannel & { + channel_type: 'TextChannel', last_message: string } - export type Channel = (SavedMessagesChannel | DirectMessageChannel | GroupChannel | TextChannel) & { nonce?: string } + export type VoiceChannel = ServerChannel & { + channel_type: 'VoiceChannel' + } + + export type Channel = (SavedMessagesChannel | DirectMessageChannel | GroupChannel | TextChannel | VoiceChannel) & { nonce?: string } export type Message = { _id: string, @@ -198,7 +205,8 @@ export namespace Channels { attachments?: Attachment[], edited?: { $date: string }, embeds?: Embed[], - mentions?: string[] + mentions?: string[], + replies?: string[] } export type SystemMessage = diff --git a/src/api/permissions.ts b/src/api/permissions.ts index be524aba..12acf5ff 100644 --- a/src/api/permissions.ts +++ b/src/api/permissions.ts @@ -94,7 +94,8 @@ export class PermissionCalculator { + ChannelPermission.ManageChannel + ChannelPermission.VoiceCall + ChannelPermission.InviteOthers; - case 'TextChannel': { + case 'TextChannel': + case 'VoiceChannel': { let server = this.client.servers.get(channel.server); if (typeof server === 'undefined') return 0; @@ -103,6 +104,7 @@ export class PermissionCalculator { } else { return ChannelPermission.View + ChannelPermission.SendMessage + + ChannelPermission.VoiceCall + ChannelPermission.InviteOthers; } } diff --git a/src/api/routes.ts b/src/api/routes.ts index 0ec6c878..46db0b53 100644 --- a/src/api/routes.ts +++ b/src/api/routes.ts @@ -369,7 +369,8 @@ type Routes = data: { content: string, nonce: string, - attachments?: string[] + attachments?: string[], + replies?: { id: string, mention: boolean }[] }, response: Channels.Message } @@ -524,15 +525,16 @@ type Routes = response: Servers.Ban[] } | { - // Create a new text channel for a server + // Create a new server channel method: 'POST', route: `/servers/${Id}/channels`, data: { + type?: 'Text' | 'Voice', name: string, description?: string, nonce: string }, - response: Channels.TextChannel + response: Channels.TextChannel | Channels.VoiceChannel } | { // Fetch a server's invites