From 32c3306bf050b9627f420a1c2a91a26fa336c696 Mon Sep 17 00:00:00 2001 From: ayntee Date: Sat, 2 Jan 2021 17:10:18 +0400 Subject: [PATCH] fix: outdated pin & unpin handlers and endpoints --- src/api/handlers/message.ts | 6 ++++-- src/util/constants.ts | 2 ++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/api/handlers/message.ts b/src/api/handlers/message.ts index 10b6e0e54..4525af07a 100644 --- a/src/api/handlers/message.ts +++ b/src/api/handlers/message.ts @@ -68,7 +68,8 @@ export async function pin(channelID: string, messageID: string) { ) { throw new Error(Errors.MISSING_MANAGE_MESSAGES); } - return RequestManager.put(endpoints.CHANNEL_MESSAGE(channelID, messageID)); + + return RequestManager.put(endpoints.CHANNEL_PIN(channelID, messageID)); } /** Unpin a message in a channel. Requires MANAGE_MESSAGES. */ @@ -82,8 +83,9 @@ export async function unpin(channelID: string, messageID: string) { ) { throw new Error(Errors.MISSING_MANAGE_MESSAGES); } + return RequestManager.delete( - endpoints.CHANNEL_MESSAGE(channelID, messageID), + endpoints.CHANNEL_PIN(channelID, messageID), ); } diff --git a/src/util/constants.ts b/src/util/constants.ts index 8a86a20e9..abc2154ef 100644 --- a/src/util/constants.ts +++ b/src/util/constants.ts @@ -31,6 +31,8 @@ export const endpoints = { `${baseEndpoints.BASE_URL}/channels/${id}/messages/${messageID}`, CHANNEL_MESSAGES: (id: string) => `${baseEndpoints.BASE_URL}/channels/${id}/messages`, + CHANNEL_PIN: (channelID: string, messageID: string) => + `${baseEndpoints.BASE_URL}/channels/${channelID}/pins/${messageID}`, CHANNEL_PINS: (id: string) => `${baseEndpoints.BASE_URL}/channels/${id}/pins`, CHANNEL_BULK_DELETE: (id: string) => `${baseEndpoints.BASE_URL}/channels/${id}/messages/bulk-delete`,