SinisterRectus / Discordia

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

TextChannel: indicate getMessage can pull from cache #353

Closed Bilal2453 closed 2 years ago

Bilal2453 commented 2 years ago
function TextChannel:getMessage(id)
    id = Resolver.messageId(id)
    local message = self._messages:get(id)
    if message then
        return message
    else
        local data, err = self.client._api:getChannelMessage(self._id, id)
        if data then
            return self._messages:_insert(data)
        else
            return nil, err
        end
    end
end

As we see here, getMessage checks first the messages cache, and if it has it that will be returned instead of making an HTTP request. So the method may make an HTTP request, not always.