Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
nospam2k opened this issue Feb 28, 2023 · 4 comments

Comments

@nospam2k
Copy link

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
Copy link
Author

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`)
        }

@javis86
Copy link
Collaborator

javis86 commented Feb 28, 2023

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

@nospam2k
Copy link
Author

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.

@dochardi
Copy link
Contributor

dochardi commented Jun 16, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants