spacebarchat / server

Spacebar server - A reimplementation of the Discord.com backend, built with Typescript and love
https://spacebar.chat
GNU Affero General Public License v3.0
1.41k stars 242 forks source link

Implement Badges array #1063

Open Puyodead1 opened 1 year ago

Puyodead1 commented 1 year ago

user profiles on Discord now have a badges array which are used instead to display badges in the client.

{
    "badges": [
        {
            "description": "Discord Staff",
            "icon": "5e74e9b61934fc1f67c65515d1f7e60d",
            "id": "staff",
            "link": "https://discord.com/company"
        }
    ],
    "guild_badges": [] // per guild badges?
}

This could also be used for custom badges.

Puyodead1 commented 1 year ago

as pointed out by erkin in discord, custom badges should use snowflake ids

TheArcaneBrony commented 1 year ago

using snowflakes for badges seems counterintuitive, as it makes server administration harder

Puyodead1 commented 1 year ago

using snowflakes for badges seems counterintuitive, as it makes server administration harder

how so?

erkinalp commented 1 year ago

@TheArcaneBrony If we have snowflake IDs, then the runtime badge registration flows would not need to explicitly supply an ID before creating a new badge. Such runtime-registered badges could be useful for dynamically generated badges such as boost streaks and XP points.

TheArcaneBrony commented 1 year ago

wait im thinking... snowflake for row ids in the list of badges? why not use (user_id, badge_id) as unique index/key instead? this would prevent eg. 2 nitro badges on a user

erkinalp commented 1 year ago

@TheArcaneBrony In the model I suggested, the badges that are not directly derived from flags would all be derived at runtime using generators registered to a snowflake-indexed vtable. The snowflake would be the ID of the badge generator function for that type of the badge, not the ID of the specific instance of the badge.