Skip to content

Commit

Permalink
added deleteChannel method
Browse files Browse the repository at this point in the history
  • Loading branch information
alechkos committed Nov 4, 2023
1 parent 2baf22a commit 11c184e
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
2 changes: 2 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1361,6 +1361,8 @@ declare namespace WAWebJS {
* 3 for NONE reactions to be avaliable
*/
setReactionSetting(reactionCode: number): Promise<boolean>;
/** Deletes the channel you created */
deleteChannel(): Promise<boolean>;
}

export interface MessageSearchOptions {
Expand Down
18 changes: 18 additions & 0 deletions src/structures/Channel.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,24 @@ class Channel extends Base {
return success;
}

/**
* Deletes the channel you created
* @returns {Promise<boolean>} Returns true if the operation completed successfully, false otherwise
*/
async deleteChannel() {
return await this.client.pupPage.evaluate(async (channelId) => {
const channel = await window.WWebJS.getChannel(channelId);
if (!channel) return false;
try {
await window.Store.ChannelUtils.deleteNewsletterAction(channel);
return true;
} catch (err) {
if (err.name === 'ServerStatusCodeError') return false;
throw err;
}
}, this.id._serialized);
}

/**
* Internal method to change the channel metadata
* @param {string|number|MessageMedia} value The new value to set
Expand Down
1 change: 1 addition & 0 deletions src/util/Injected.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ exports.ExposeStore = (moduleRaidStr) => {
...window.mR.findModule('queryAndUpdateNewsletterMetadataAction')[0],
...window.mR.findModule('createNewsletterQuery')[0],
...window.mR.findModule('editNewsletterMetadataAction')[0],
...window.mR.findModule('deleteNewsletterAction')[0],
};

if (!window.Store.Chat._find) {
Expand Down

0 comments on commit 11c184e

Please sign in to comment.