SinisterRectus / Discordia

Discord API library written in Lua for the Luvit runtime environment
MIT License
688 stars 144 forks source link

[FIX] How to fix other people's messages not showing with selfbots #381

Closed multikirin closed 1 year ago

multikirin commented 1 year ago

honestly, there are better ways to fix this, but I am too lazy to do it so here's a temporary solution (this code assumes the actual "message" object is called _message, and the one you'll use is called message)

        message={}
        message.content=_message.channel:getMessages(1):get(1)
        fakemessage =  {
                __index = function(mytable, key)
                        if _message[key] ~= nil then return _message[key] end
                        if key == "content" then
                                return _message.channel:getMessages(1):get(1)
                        else
                                return mytable[key]
                        end
                end
        }
        message=setmetatable(message,fakemessage)
truemedian commented 1 year ago

What exactly is this supposed to accomplish? The code is nonsensical and the title of this issue doesn't make any sense.

multikirin commented 1 year ago

What exactly is this supposed to accomplish? The code is nonsensical and the title of this issue doesn't make any sense.

sorry if i wasn't clear, but if you use a selfbot, receive a message from a person that isnt the selfbot, and try to read message.content, it will be empty. this is a bug reported at least two years ago. what the code does is create a message table, add the key 'content' to it with the content of the last message sent in the channel (which, unless the bot is super laggy, is the content we want), make a metatable that, for whatever key that isn't 'content', returns the value of the original message object. in the case that it is the 'content' key, it gives the aforementioned last message content. This works because, although self bots don't receive the message content, they can see the message history.

To be fair, the code is probably very unoptimized, but it works

multikirin commented 1 year ago

oops didnt mean to close

multikirin commented 1 year ago

another issue is that selfbots cannot create GCs

truemedian commented 1 year ago

That code adds the last message as the content of the message, not the content of the last message, but regardless selfbots are NOT supported. As noted in the issue you've linked, selfbots are against Discord ToS and as such we will not be supporting any use case of them.

multikirin commented 1 year ago

That code adds the last message as the content of the message, not the content of the last message, but regardless selfbots are NOT supported. As noted in the issue you've linked, selfbots are against Discord ToS and as such we will not be supporting any use case of them.

now that you said that, it's true, but for some reason it works. Anyways, I'll close this issue