Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Embed for project content? #28

Open
gniftygnome opened this issue Nov 12, 2023 · 14 comments
Open

Embed for project content? #28

gniftygnome opened this issue Nov 12, 2023 · 14 comments
Labels
Discord enhancement New feature or request

Comments

@gniftygnome
Copy link

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
Copy link
Author

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

discord

@modmuss50
Copy link
Owner

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. 🤔

@modmuss50 modmuss50 added enhancement New feature or request Discord labels Nov 13, 2023
@gniftygnome
Copy link
Author

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
Copy link
Owner

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
Copy link
Owner

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
Copy link
Author

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.

@Awakened-Redstone
Copy link
Contributor

The PR for embed support was merged.
The feature is a bit limited as of right now, but I plan to later provide more control over the embeds. I will first look at how it can be structured so it is easy to use and understand

@gniftygnome
Copy link
Author

It seems like things added in the PR have to be strings, probably unintentionally. For example, this config almost works[*] (note the quotes and the call to .toString()), but it bails out insisting hex strings have to start with # even though the docs say it's optional. Passing an Integer itself fails (the error states it must be a string).

  • Where by "works" I mean not aborting with an error. I'll reserve further judgement until I get it to actually post to Discord.
            style {
                link = "INLINE"
                look = "MODERN"
                color = Integer.decode(project.project_color).toString()
                thumbnailUrl = project.project_logo
            }

@Awakened-Redstone
Copy link
Contributor

About the hex, I originally made it with optional # and integer support, but @modmuss50 though it would be better to have it only as string. It makes sense, the number support was more to allow scripts that already used integer colors to be able to work easily, but that is a small set of scripts. It has been a while since I had worked on the script so I didn't remember much why I added integer support, and I guess we both forgot to update the docs on it

6e58d58#diff-e61f4a8c2ab2a88e08e1206c53815311505d11e38c13c0dd8e358ccb5755b390L317-R322

@modmuss50
Copy link
Owner

I have updated the docs to reflect what was merged.

@gniftygnome
Copy link
Author

I have updated the docs to reflect what was merged.

Not entirely, I think. Two things:

  1. These do not work as documented, only if you quote them (or at least, quoting them makes the early crash go away). The reason I guessed this was by looking at https://github.com/modmuss50/mod-publish-plugin/blob/main/src/main/kotlin/me/modmuss50/mpp/platforms/discord/DiscordWebhookTask.kt#L119-L120
look = "MODERN"
link = "BUTTON"
  1. What is the exact syntax of color? An example that is not just color = "github" would be nicer. I am guessing maybe it is #112233 but am I right about that? (Ours will all have to change, as they are stored as 0x112233 today.)

@gniftygnome
Copy link
Author

Re (1) above, here is an example of what happens if they are not quoted:
https://github.com/TerraformersMC/Biolith/actions/runs/11878112163/job/33098395841

@Awakened-Redstone
Copy link
Contributor

I have updated the docs to reflect what was merged.

Not entirely, I think. Two things:

1. These do not work as documented, only if you quote them (or at least, quoting them makes the early crash go away).  The reason I guessed this was by looking at https://github.com/modmuss50/mod-publish-plugin/blob/main/src/main/kotlin/me/modmuss50/mpp/platforms/discord/DiscordWebhookTask.kt#L119-L120
look = "MODERN"
link = "BUTTON"

This was also a miss on the documentation, it used to not require it, but it was changed to string as it was proffered than the way it was being done before

2. What is the exact syntax of `color`?  An example that is not just `color = "github"` would be nicer.  I am guessing maybe it is `#112233` but am I right about that?  (Ours will all have to change, as they are stored as `0x112233` today.)

I'll work on improving this on the documentation

@gniftygnome
Copy link
Author

look = "MODERN"
link = "BUTTON"

This was also a miss on the documentation, it used to not require it, but it was changed to string as it was proffered than the way it was being done before

I would expect it to work the same as publishMods.type ... maybe Modmuss is going to change that someday... But yeah as long as the docs say the right thing I guess that's really what matters.

I'll work on improving this on the documentation

👍 Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Discord enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants