From 8fc6e6098c88e7280074e4a9bdaabedc0646589e Mon Sep 17 00:00:00 2001 From: tofers Date: Sun, 25 Jun 2023 22:25:49 +0300 Subject: [PATCH] feat: add or remove labels (#1915) * add or remove labels * Strings use singlequote * add event chat change labels * Revert "add event chat change labels" --- example.js | 12 ++++++++++++ index.d.ts | 5 +++++ src/Client.js | 29 +++++++++++++++++++++++++++++ src/structures/Chat.js | 9 +++++++++ 4 files changed, 55 insertions(+) diff --git a/example.js b/example.js index 529a8c4..4885398 100644 --- a/example.js +++ b/example.js @@ -210,6 +210,18 @@ client.on('message', async msg => { msg.reply('I can only edit my own messages'); } } + } else if (msg.body === '!updatelabels') { + const chat = await msg.getChat(); + await chat.changeLabels([0, 1]); + } else if (msg.body === '!addlabels') { + const chat = await msg.getChat(); + let labels = (await chat.getLabels()).map(l => l.id); + labels.push('0'); + labels.push('1'); + await chat.changeLabels(labels); + } else if (msg.body === '!removelabels') { + const chat = await msg.getChat(); + await chat.changeLabels([]); } }); diff --git a/index.d.ts b/index.d.ts index a9864d4..7e2b86c 100644 --- a/index.d.ts +++ b/index.d.ts @@ -71,6 +71,9 @@ declare namespace WAWebJS { /** Get all current Labels */ getLabels(): Promise + + /** Change labels in chats */ + addOrRemoveLabels(labelIds: Array, chatIds: Array): Promise /** Get Label instance by ID */ getLabelById(labelId: string): Promise