Basic example
See the following minimal example showing how a message can be sent to a discord channel using a webhook.
publishMods {
// ...
discord {
webhookUrl = providers.environmentVariable("DISCORD_WEBHOOK")
}
}
Please note, when using the discord webhook you must also specify the projectSlug
in any CurseForge publications. This is due to limitations in the CurseForge API.
By default discord will publish a message with the changelog to the supplied webhook. A link to all of the platforms will also be included.
publishMods {
// ...
discord {
// Pass in the secret webhook URL. Required
webhookUrl = providers.environmentVariable("DISCORD_WEBHOOK")
// Pass in the secret webhook URL to post the messages when running a dry run. Optional
dryRunWebhookUrl = providers.environmentVariable("DISCORD_WEBHOOK_DRY_RUN")
// Set the username used to send the webhook, defaults to "Mod Publish Plugin"
username = "My Cool Mod"
// Set the avatar image url for the webhook, defaults to none.
avatarUrl = "https://placekitten.com/500/500"
// Set the content message, in this example a header is added before the changelog. Defaults to just the changelog
content = changelog.map { "# A new version of my cool mod has been released! \n" + it}
// If you wish to only link to certain platform you can do the following
setPlatforms(publishMods.platforms.curseforge, publishMods.platforms.github)
// Instead if you wish to link to all platform in a specific Gradle project you can do the following
setPlatformsAllFrom(project(":child1"), project(":child2"))
}
}
You can customise the platform specific message by using the announcementTitle
property present on all of the platforms. This will be used as the title of the embed.
publishMods {
curseforge {
announcementTitle = "Download from CurseForge"
}
}
The webhook message can be customized to different styles
The look can be set to CLASSIC
or MODERN
Look examples
Classic look
The classic look is used by default by the plugin
Modern look
publishMods {
// ...
discord {
// ...
style {
// ...
look = "MODERN"
}
}
}
The style tag also has the options thumbnailUrl
and color
, this options allow you to customize more the look of your embeds
The color
option must be a string, the string must be a full RRGGBB
hex prefixed with a #
.
The string can also be modrinth
, github
or curseforge
, with those working as alias for the colors used for the embed links for those platforms
publishMods {
// ...
discord {
// ...
style {
// ...
look = "MODERN"
thumbnailUrl = "https://example.com"
color = "#f6f0fc"
}
}
}
You can also set your links to be posted as EMBED
or BUTTON