modmuss50 / mod-publish-plugin

A Gradle plugin to publish mods to a range of destinations
https://modmuss50.github.io/mod-publish-plugin/
MIT License
50 stars 7 forks source link

Embed for project content? #28

Open gniftygnome opened 8 months ago

gniftygnome commented 8 months ago

I've been working on trying to use MPP in Ferry so I don't have to maintain a hot mess of gradle script to publish Terraformers mods. There are a few things I haven't figured out how to reproduce in MPP's Discord publishing. I'll show how Ferry creates its Discord message below.

The main thing I'm wondering is would you consider using an embed for the project data? This would allow setting a thumbnail on the project content, and it would also allow setting the embed color to the project's color scheme.

Here is the Ferry code for Discord messages:

        def result = DiscordBuilder.createForm {
            if (project.use_project_username.toBoolean()) {
                avatar_url = project.project_logo
                username = project.project_name
            }
            embed {
                color = Integer.decode(project.project_color)
                author {
                    name = project.project_name + stabilitySuffix
                    url = project.project_url
                }
                thumbnail { url = project.project_logo }
                title = "$project.project_name v$version for $project.minecraft_version Released"
                url = release_url
                field {
                    name = "Changes:"
                    value = discordChangelog
                }
                field {
                    name = "Downloads:"
                    value = "[$modrinth_emote Modrinth]($modrinthDownloadLink)\n[$curseforge_emote CurseForge]($curseforgeDownloadLink)\n[$github_emote GitHub]($githubDownloadLink)"
                }
                footer {
                    text = "A $project.loader_name Mod"
                    icon_url = project.loader_icon
                }
            }
        }.send(System.getenv().DISCORD_ANNOUNCEMENT_WEBHOOK)
gniftygnome commented 8 months ago

Here's an example of how Ferry publishes look in Discord (what I'm trying to sort of replicate):

discord

modmuss50 commented 8 months ago

That does look better 👍 Im not sure if I should just update the existing code to use this format, or maybe it would be best to provide some form of customistation for the embed. 🤔

gniftygnome commented 8 months ago

I'm not sure how easy it would be to fit an indefinite number of publish results into a single embed. Ferry only generates at most three plus the mod loader badges. (Speaking of which, it would be cool to have automatic mod loader badges without needing to put the emotes into project configuration, but I don't know if that would be in scope for MPP.)

We do limit the changelog to ten lines, though. I think I recall mention in one of the MPP issues of having MPP generate changelogs from GH. Ferry does this, if you're interested. However, Ferry requires the version numbers for the previous published version and the new published version as properties. Even so, it's a messy process. https://github.com/TerraformersMC/GradleScripts/blob/2.6/ferry.gradle#L35-L96

modmuss50 commented 8 months ago

I dont have a solid idea for an nice API to allow customising of the webhook, Ill have a play and see what I can come up with.

As for the changelogs I think this is worth a new issue to discuss. For Fabric and my own projects ive been using: https://github.com/FabricMC/fabric-action-scripts/blob/main/src/changelog.ts the problem is this is specific to github actions.

modmuss50 commented 8 months ago

Ive had a play and havent come up with a nice idea for this (gradle makes it kinda pain), my best idea is to have an option to select between diffrent styles? Such as the current one, and the one you suggested in this issue, the API would be something like:

discord {
    style = "classic" // what the plugin has now
    // or
    style = "modern" // what you suggested above
}

(better names TBD)

(Speaking of which, it would be cool to have automatic mod loader badges without needing to put the emotes into project configuration, but I don't know if that would be in scope for MPP.)

Have you got any ideas how this would be done?

gniftygnome commented 8 months ago

Ive had a play and havent come up with a nice idea for this

Yeah ... I didn't have something better to suggest. Outside allowing the user to pass in a complete embed definition, which seems likely too technical for the API style you've provided.

my best idea is to have an option to select between diffrent styles?

Yeah, that works for me. I agree it's probably the simplest option. And then a couple optional settings that get ignored if the style is classic.

(Speaking of which, it would be cool to have automatic mod loader badges without needing to put the emotes into project configuration, but I don't know if that would be in scope for MPP.)

Have you got any ideas how this would be done?

In the scope of Minecraft modding, there are only a few loaders; MPP could just keep its own list of the loader badges and emit them at the bottom of the embed or in an extra (optional?) embed based on what loaders are in the settings (modLoaders). The main reason to do this is it helps just a wee bit with the knee-jerk "port it to X" comments. I think those are more common when somebody sees something and gets excited but finds they can only download it for $not_my_favorite_loader. This isn't a big deal though; I could put them further up (in the content) or even just leave it off.