@@ -99,3 +99,56 @@ some interactive options called `Block elements`_::
99
99
$chatter->send($chatMessage);
100
100
101
101
.. _`Block elements` : https://api.slack.com/reference/block-kit/block-elements
102
+
103
+ Adding Interactions to a Discord Message
104
+ --------------------------------------
105
+
106
+ With a Discord message, you can use the
107
+ :class: `Symfony\\ Component\\ Notifier\\ Bridge\\ Discord\\ DiscordOptions ` to add
108
+ some interactive options called `Embed elements `_::
109
+
110
+ use Symfony\Component\Notifier\Bridge\Discord\Block\DiscordEmbed;
111
+ use Symfony\Component\Notifier\Bridge\Discord\Block\DiscordFieldEmbedObject;
112
+ use Symfony\Component\Notifier\Bridge\Discord\Block\DiscordFooterEmbedObject;
113
+ use Symfony\Component\Notifier\Bridge\Discord\Block\DiscordMediaEmbedObject;
114
+ use Symfony\Component\Notifier\Bridge\Discord\DiscordOptions;
115
+ use Symfony\Component\Notifier\Message\ChatMessage;
116
+
117
+ $chatMessage = new ChatMessage('');
118
+
119
+ // Create Discord Embed
120
+ $discordOptions = (new DiscordOptions())
121
+ ->username('connor bot')
122
+ ->addEmbed((new DiscordEmbed())
123
+ ->color(2021216)
124
+ ->title('New song added!')
125
+ ->thumbnail((new DiscordMediaEmbedObject())
126
+ ->url('https://i.scdn.co/image/ab67616d0000b2735eb27502aa5cb1b4c9db426b'))
127
+ ->addField((new DiscordFieldEmbedObject())
128
+ ->name('Track')
129
+ ->value('[Common Ground](https://open.spotify.com/track/36TYfGWUhIRlVjM8TxGUK6)')
130
+ ->inline(true)
131
+ )
132
+ ->addField((new DiscordFieldEmbedObject())
133
+ ->name('Artist')
134
+ ->value('Alasdair Fraser')
135
+ ->inline(true)
136
+ )
137
+ ->addField((new DiscordFieldEmbedObject())
138
+ ->name('Album')
139
+ ->value('Dawn Dance')
140
+ ->inline(true)
141
+ )
142
+ ->footer((new DiscordFooterEmbedObject())
143
+ ->text('Added ...')
144
+ ->iconUrl('https://upload.wikimedia.org/wikipedia/commons/thumb/1/19/Spotify_logo_without_text.svg/200px-Spotify_logo_without_text.svg.png')
145
+ )
146
+ )
147
+ ;
148
+
149
+ // Add the custom options to the chat message and send the message
150
+ $chatMessage->options($discordOptions);
151
+
152
+ $chatter->send($chatMessage);
153
+
154
+ .. _`Embed elements` : https://discord.com/developers/docs/resources/webhook
0 commit comments