node-red-contrib-discord-advanced
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
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,
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`)
}
In which scenarios would you use this feature? Do you have some in mind?
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.
do this always request? if yes i can add its but then withe msg. For how many you wane del.