How can i make a table referencing something like this?

history = {
    {
        role = "user",
        parts = {
            {
                text = "hi"
            }
        }
    },
    {
        role = "model",
        parts = {
            {
                text = "sup"
            }
        }
    }
}

can anyone help?

Are you trying to store that object’s data in a database? Or is that supposed to be a data model itself?

Assuming the first, how you’d store this depends on if parts ever has a more ‘deep’ object than just containing a single string of text.

As shown, you should create a database table named history with columns role and parts.

ok
thanks sir

and yes, im trying to store messages when a user sends something

its my first time using this app lol

If you’re just looking to create a deleted/edited message log you can probably just use the message cache, no DB required and it’ll automatically provide the previous message content alongside the message edited/deleted events. You can enable it in settings.

The schema you provided doesn’t really store messages, you’d probably want a table like message_history with columns like user_id, channel_id, content.

ok, ill try this. im only used to coding stuff like this, but im not very expert at components.

but how can i get my bot to have access to the message caches?

You can only access the message cache on edited/deleted events (there’s outputs for previous message content if it is available from the cache), there’s no way to query it directly.

can you add a feature like that someday? i’ll just figure it out by myself then.

i made my own message cache system a long ago and it might be broken, but you can try it if you want
https://api.inventor.gg/library/116

thanks man, i appreciate it. how does it work?

logs when messages are sent, deletes them from the db when deleted

ok, am i allowed to use this?

yes, i wouldnt put it out to the public if i didnt :joy: