Closed xirpy closed 4 years ago
The issue here is that, the message is sent instantly. Mee6 will actually delete the first message after the other messages are sent. Maybe it doesn't looks like it because of discord latency but that's actually how it works. We could eventually delete the message just sent in all other channels if it is delete in one channel. However there are no really simple and convenient way to do this either
In theory, it's not too difficult to achieve, however, it will add to the wait time to send the message on top of the latency of the server and the latency from the server and Discord. Now the idea is... Message is sent, wait for 1 to 2 seconds to try and retrieve the message from Discord. If the message no longer exists, terminate the function then. Otherwise, send the message. Add the message to a map, and listen for the delete event. When the delete event fires, if the message ID is within the map of messages, delete the message from Discord and remove it from the map.
yes that's also a solution to achieve this. However this adds latency to the whole process. Delaying every message by even one second could quickly get annoying Also this would be quite vulnerable to edge case (delay in suppression, spam etc...) Might still be the easiest way to do this though.
Otherwise if you start listening to the delete event, you'd better send the message everywhere and then delete I think 🤷♂ This brings in the whole complexity of keeping tracks of all messages sent. Adding this features correctly, would actually mean rewriting the whole thing in a slightly better structured bot instead of this one file script put together. Since adding more and more features actually changes this simple bot in a more complex one.
Alright, here a mergeable implementation I would accept without too much refactoring and an effective design. I will personally not do it yet so anyone feel free to PR:
{ "channelID": customMap() }
.
The Map map messageID => [ { channelID, messageID } ]
This basically link the original message to all the crossposted messages.Then listen to messageDelete
event. Get the message and delete the message accordingly if needed.
Alright, here a mergeable implementation I would accept without too much refactoring and an effective design. I will personally not do it yet so anyone feel free to PR:
- Create a Structure that extends Map and add a limit (eg: only store 50 items.) Adding new items would delete the older one (older = first added. Reminder that Map keeps elements order).
- Add an object of
{ "channelID": customMap() }
. The Map mapmessageID => [ { channelID, messageID } ]
This basically link the original message to all the crossposted messages.Then listen to
messageDelete
event. Get the message and delete the message accordingly if needed.
So until this functionality is added the bot will not delete any message pushed by the webhook.. in other words deleting messages in one channel will make any changes in other connected channels.
Going a little off topic here but somewhat related: Since reactions to messages don't happen at message creation these are also not pushed to linked channels. Part of this seems like a limitation of webhooks and the bot would only be able to react to messages itself (with proper permissions) and cannot push reactions that appear to be made by the original user.. who may not even be on the link channel server to begin with. Also the bot doesn't seem to require any permissions at this time to function as intended.. I consider this to be pretty nice and a feature as I am immediately suspicious of any bots that request more permissions than what is necessary.
Yes you are right, the bot at the current state would never delete any messages.
There are unfortunately no way (at least any that I can see) to reflect reaction, as the bot could at max add ONE reaction to a message, and that's granted he has access to the emoji the user used which would not necessarily be the case.
As for the permission yes you are right, since webhook creation is handled by the user setting up the bot, the bot actually only need read messages
permission.
I'm however planning to add message delete support as it has been requested in this thread but also by the community I am primarily developing this bot for.
The bot will then need the manage message
permission to be able to delete messages.
Be assured that not giving the bot this permission will simply prevent him to delete any messages, so if you don't trust the script and don't want to give permission to the bot, it should still function without issues..
implemented in latest release. It is optional through the deleteMessage
option
How about we try an out-of-the-box solution for reactions.
What about instead of trying to recreate reactions, which is impossible, instead just send a reply to the user's message with the same emoji as the message content. I know it wouldn't be the same, but at least it would cover many use cases.
This can quickly gets very spammy and will imho obfuscate the channel for nothing. I guess depending the use case it can work. But in most case I don't think this is a very good idea. This could eventually work as an optional feature but I'd love to know more about the use case, because for my perspective this wouldn't work out very well. Maybe I am missing something though
hello, this is a suggestion
is there a way to make the bot check if the message was deleted by another bot before of being sent?, because in my server exist a channel that no one can send link, and when this person send the link, the bot (Mee6 example) deleted this message but the bot (Cross-Server) send the message anyway
i hope this can be made! :D