mirror of
https://github.com/Luzifer/discord-community.git
synced 2024-11-09 15:40:03 +00:00
Add support for message content for reaction role posts
Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
parent
473808dfa0
commit
0345d3c90f
2 changed files with 16 additions and 3 deletions
|
@ -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
|
// @attr discord_channel_id required string "" ID of the Discord channel to post the message to
|
||||||
channelID := m.attrs.MustString("discord_channel_id", nil)
|
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{
|
msgEmbed := &discordgo.MessageEmbed{
|
||||||
// @attr embed_color optional int64 "0x2ECC71" Integer / HEX representation of the color for the embed
|
// @attr embed_color optional int64 "0x2ECC71" Integer / HEX representation of the color for the embed
|
||||||
Color: int(m.attrs.MustInt64("embed_color", ptrInt64(streamScheduleDefaultColor))),
|
Color: int(m.attrs.MustInt64("embed_color", ptrInt64(streamScheduleDefaultColor))),
|
||||||
|
@ -100,9 +103,18 @@ func (m modReactionRole) Setup() error {
|
||||||
}
|
}
|
||||||
|
|
||||||
if managedMsg == nil {
|
if managedMsg == nil {
|
||||||
managedMsg, err = m.discord.ChannelMessageSendEmbed(channelID, msgEmbed)
|
managedMsg, err = m.discord.ChannelMessageSendComplex(channelID, &discordgo.MessageSend{
|
||||||
} else if !isDiscordMessageEmbedEqual(managedMsg.Embeds[0], msgEmbed) {
|
Content: contentString,
|
||||||
_, err = m.discord.ChannelMessageEditEmbed(channelID, managedMsg.ID, msgEmbed)
|
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 {
|
if err != nil {
|
||||||
return errors.Wrap(err, "updating / creating message")
|
return errors.Wrap(err, "updating / creating message")
|
||||||
|
|
|
@ -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 |
|
| `discord_channel_id` | ✅ | string | | ID of the Discord channel to post the message to |
|
||||||
| `embed_title` | ✅ | string | | Title of the embed |
|
| `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 `:<emote-name>:<emote-id>`. `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. |
|
| `reaction_roles` | ✅ | []string | | List of strings in format `emote=role-id[:set]`. `emote` equals an unicode emote (✅) or a custom emote in form `:<emote-name>:<emote-id>`. `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_color` | | int64 | `0x2ECC71` | Integer / HEX representation of the color for the embed |
|
||||||
| `embed_description` | | string | | Description for the embed block |
|
| `embed_description` | | string | | Description for the embed block |
|
||||||
| `embed_thumbnail_height` | | int64 | | Height of the thumbnail |
|
| `embed_thumbnail_height` | | int64 | | Height of the thumbnail |
|
||||||
|
|
Loading…
Reference in a new issue