From 0345d3c90f9dd1018772943684cb1a81fc0a605a Mon Sep 17 00:00:00 2001 From: Knut Ahlers Date: Sun, 8 Aug 2021 13:57:28 +0200 Subject: [PATCH] Add support for message content for reaction role posts Signed-off-by: Knut Ahlers --- mod_reactionRole.go | 18 +++++++++++++++--- wiki/Home.md | 1 + 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/mod_reactionRole.go b/mod_reactionRole.go index 4901bc6..f9e7703 100644 --- a/mod_reactionRole.go +++ b/mod_reactionRole.go @@ -55,6 +55,9 @@ func (m modReactionRole) Setup() error { // @attr discord_channel_id required string "" ID of the Discord channel to post the message to channelID := m.attrs.MustString("discord_channel_id", nil) + // @attr content optional string "" Message content to post above the embed + contentString := m.attrs.MustString("content", ptrStringEmpty) + msgEmbed := &discordgo.MessageEmbed{ // @attr embed_color optional int64 "0x2ECC71" Integer / HEX representation of the color for the embed Color: int(m.attrs.MustInt64("embed_color", ptrInt64(streamScheduleDefaultColor))), @@ -100,9 +103,18 @@ func (m modReactionRole) Setup() error { } if managedMsg == nil { - managedMsg, err = m.discord.ChannelMessageSendEmbed(channelID, msgEmbed) - } else if !isDiscordMessageEmbedEqual(managedMsg.Embeds[0], msgEmbed) { - _, err = m.discord.ChannelMessageEditEmbed(channelID, managedMsg.ID, msgEmbed) + managedMsg, err = m.discord.ChannelMessageSendComplex(channelID, &discordgo.MessageSend{ + Content: contentString, + Embed: msgEmbed, + }) + } else if !isDiscordMessageEmbedEqual(managedMsg.Embeds[0], msgEmbed) || managedMsg.Content != contentString { + _, err = m.discord.ChannelMessageEditComplex(&discordgo.MessageEdit{ + Content: &contentString, + Embed: msgEmbed, + + ID: managedMsg.ID, + Channel: channelID, + }) } if err != nil { return errors.Wrap(err, "updating / creating message") diff --git a/wiki/Home.md b/wiki/Home.md index 6434c00..294ce57 100644 --- a/wiki/Home.md +++ b/wiki/Home.md @@ -117,6 +117,7 @@ Creates a post with pre-set reactions and assigns roles on reaction | `discord_channel_id` | ✅ | string | | ID of the Discord channel to post the message to | | `embed_title` | ✅ | string | | Title of the embed | | `reaction_roles` | ✅ | []string | | List of strings in format `emote=role-id[:set]`. `emote` equals an unicode emote (✅) or a custom emote in form `::`. `role-id` is the integer ID of the guilds role to add with this emote. If `:set` is added at the end, the role will only be added but not removed when the reaction is removed. | +| `content` | | string | | Message content to post above the embed | | `embed_color` | | int64 | `0x2ECC71` | Integer / HEX representation of the color for the embed | | `embed_description` | | string | | Description for the embed block | | `embed_thumbnail_height` | | int64 | | Height of the thumbnail |