node-red-contrib-discord-advanced icon indicating copy to clipboard operation
node-red-contrib-discord-advanced copied to clipboard

I would like to add bulkDelete but having problems figuring out how to get the right parameters

Open nospam2k opened this issue 2 years ago • 4 comments

I would like to modify the deleteMessage routine to add bulkdelete but I'm not sure how to get the right parameter. I have seen messages.channel.bulkDelete(100) as an example,

nospam2k avatar Feb 28 '23 06:02 nospam2k

I figured it out. It would be nice to see this as a regular feature! I'm not familiar enough with Github to do it properly.

      const deleteMessage = async () => {
          try {
            let message = await getMessage(channel, messageId);
            let resultMessage = await message.delete();
            setSuccess(`message ${resultMessage.id} deleted`, resultMessage);
          } catch (err) {
            setError(err);
          }
        }

        const deleteBulk = async () => {
          try {
            let channelInstance = await getChannel(channel);
            let resultMessage = await channelInstance.bulkDelete(100);
            setSuccess(`100 messages deleted`, resultMessage);
          } catch (err) {
            setError(err);
          }
        }
     switch (action.toLowerCase()) {
          case 'create':
            await createMessage();
            break;
          case 'edit':
            await editMessage();
            break;
          case 'delete':
            await deleteMessage();
            break;
          case 'deletebulk':
            await deleteBulk();
            break;
          case 'reply':
            await replyMessage();
            break;
          case 'react':
            await reactToMessage();
            break;
          default:
            setError(`msg.action has an incorrect value`)
        }

nospam2k avatar Feb 28 '23 06:02 nospam2k

In which scenarios would you use this feature? Do you have some in mind?

javis86 avatar Feb 28 '23 17:02 javis86

We have a channel that we use for our church where we have announcements and requests Sun morning, Sun night and Wed that have to be deleted manually before every service. What would probably be better though is to only delete messages that aren't pinned, or maybe by date, so perhaps being able to retrieve all message id's might be a better place to start. Then they can be iterated through depending on certain criteria such as date or pin or from a particular user.

nospam2k avatar Feb 28 '23 18:02 nospam2k

do this always request? if yes i can add its but then withe msg. For how many you wane del.

dochardi avatar Jun 16 '23 15:06 dochardi