Giter Club home page Giter Club logo

Comments (9)

freki785 avatar freki785 commented on July 17, 2024 1

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 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.

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.

from cross-server-bot.

Khaaz avatar Khaaz commented on July 17, 2024

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

from cross-server-bot.

Aervyon avatar Aervyon commented on July 17, 2024

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.

from cross-server-bot.

Khaaz avatar Khaaz commented on July 17, 2024

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.

from cross-server-bot.

Khaaz avatar Khaaz commented on July 17, 2024

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 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.

from cross-server-bot.

Khaaz avatar Khaaz commented on July 17, 2024

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..

from cross-server-bot.

Khaaz avatar Khaaz commented on July 17, 2024

implemented in latest release. It is optional through the deleteMessage option

from cross-server-bot.

fusillijerry89 avatar fusillijerry89 commented on July 17, 2024

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.

from cross-server-bot.

Khaaz avatar Khaaz commented on July 17, 2024

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

from cross-server-bot.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.