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