FloatingMilkshake / MechanicalMilkshake

A multipurpose Discord bot.
MIT License
10 stars 3 forks source link

Todo: logging #12

Open FloatingMilkshake opened 1 year ago

FloatingMilkshake commented 1 year ago

Includes message logging (edits & deletes) and user logging.

Message logging will require storing a cache of sent messages. Both will require storing some settings for each guild (think log channel).

auravoid commented 1 year ago

Discord provides the message that was deleted along with the message edits.

Message update provides two responses: Old content

{
    "channelId": "1012849719241883788",
    "guildId": "1007457740655968327",
    "id": "1082407022361850067",
    "createdTimestamp": 1678136344281,
    "type": 0,
    "system": false,
    "content": "hello world!",
    "authorId": "455428041586376729",
    "pinned": false,
    "tts": false,
    "nonce": "1082407016984477696",
    "embeds": [],
    "components": [],
    "attachments": [],
    "stickers": [],
    "position": null,
    "editedTimestamp": null,
    "mentions": {
        "everyone": false,
        "users": [],
        "roles": [],
        "crosspostedChannels": [],
        "repliedUser": null,
        "members": [],
        "channels": []
    },
    "webhookId": null,
    "groupActivityApplicationId": null,
    "applicationId": null,
    "activity": null,
    "flags": 0,
    "reference": null,
    "interaction": null,
    "cleanContent": "hello world!"
} 

New content:

{
    "channelId": "1012849719241883788",
    "guildId": "1007457740655968327",
    "id": "1082407022361850067",
    "createdTimestamp": 1678136344281,
    "type": 0,
    "system": false,
    "content": "Hello World!",
    "authorId": "455428041586376729",
    "pinned": false,
    "tts": false,
    "nonce": "1082407016984477696",
    "embeds": [],
    "components": [],
    "attachments": [],
    "stickers": [],
    "position": null,
    "editedTimestamp": 1678136352029,
    "mentions": {
        "everyone": false,
        "users": [],
        "roles": [],
        "crosspostedChannels": [],
        "repliedUser": null,
        "members": [],
        "channels": []
    },
    "webhookId": null,
    "groupActivityApplicationId": null,
    "applicationId": null,
    "activity": null,
    "flags": 0,
    "reference": null,
    "interaction": null,
    "cleanContent": "Hello World!"
}

And message deletions also send the content in:

{
    "channelId": "1012849719241883788",
    "guildId": "1007457740655968327",
    "id": "1082407022361850067",
    "createdTimestamp": 1678136344281,
    "type": 0,
    "system": false,
    "content": "Hello World!",
    "authorId": "455428041586376729",
    "pinned": false,
    "tts": false,
    "nonce": "1082407016984477696",
    "embeds": [],
    "components": [],
    "attachments": [],
    "stickers": [],
    "position": null,
    "editedTimestamp": 1678136352029,
    "mentions": {
        "everyone": false,
        "users": [],
        "roles": [],
        "crosspostedChannels": [],
        "repliedUser": null,
        "members": [],
        "channels": []
    },
    "webhookId": null,
    "groupActivityApplicationId": null,
    "applicationId": null,
    "activity": null,
    "flags": 0,
    "reference": null,
    "interaction": null,
    "cleanContent": "Hello World!"
}
auravoid commented 1 year ago

See 9b9c310 as a proof of concept

FloatingMilkshake commented 1 month ago

That's actually a cache thing! On Message Update, Discord provides the same data as the Message Create event. On Message Delete it provides even less. It's nice that this data could be cached, but I wouldn't depend on it.

A separate message cache should be implemented somehow.