-
Notifications
You must be signed in to change notification settings - Fork 0
/
callback-functions.html
284 lines (282 loc) · 33.8 KB
/
callback-functions.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta charset="utf-8">
<meta property="og:title" content="Using Callback Functions - D++ - The lightweight C++ Discord API Library">
<meta property="og:description" content="A lightweight C++ Discord API library supporting the entire Discord API, including Slash Commands, Voice/Audio, Sharding, Clustering and more!">
<meta name="description" content="Using Callback Functions - D++ - A lightweight C++ Discord API library supporting the entire Discord API, including Slash Commands, Voice/Audio, Sharding, Clustering and more!">
<meta property="og:image" content="https://dpp.dev/DPP-Logo.png">
<meta property="og:url" content="https://dpp.dev/">
<meta property="og:type" content="website">
<meta property="twitter:title" content="Using Callback Functions - D++ - The lightweight C++ Discord API Library">
<title>Using Callback Functions - D++ - The lightweight C++ Discord API Library</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
<link href="doxygen-awesome.css" rel="stylesheet" type="text/css"/>
<link href="style.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<script>
setTimeout(function() {
$("#main-menu").html($("#main-menu").html() + "<li><select name='vsv' onchange='window.location.href=this.options[this.selectedIndex].value'><option value='/'>master</option><option value='/10.0.35/'>10.0.35</option><option value='/10.0.34/'>10.0.34</option><option value='/10.0.33/'>10.0.33</option><option value='/10.0.32/'>10.0.32</option><option value='/10.0.31/'>10.0.31</option><option value='/10.0.30/'>10.0.30</option><option value='/10.0.29/'>10.0.29</option><option value='/10.0.28/'>10.0.28</option><option value='/10.0.27/'>10.0.27</option><option value='/10.0.26/'>10.0.26</option><option value='/10.0.25/'>10.0.25</option><option value='/10.0.24/'>10.0.24</option><option value='/10.0.23/'>10.0.23</option><option value='/10.0.22/'>10.0.22</option><option value='/10.0.21/'>10.0.21</option><option value='/10.0.20/'>10.0.20</option><option value='/10.0.19/'>10.0.19</option><option value='/10.0.18/'>10.0.18</option><option value='/10.0.17/'>10.0.17</option><option value='/10.0.16/'>10.0.16</option><option value='/10.0.15/'>10.0.15</option><option value='/10.0.14/'>10.0.14</option><option value='/10.0.13/'>10.0.13</option><option value='/10.0.12/'>10.0.12</option><option value='/10.0.11/'>10.0.11</option><option value='/10.0.10/'>10.0.10</option><option value='/10.0.9/'>10.0.9</option><option value='/10.0.8/'>10.0.8</option><option value='/10.0.7/'>10.0.7</option><option value='/10.0.6/'>10.0.6</option><option value='/10.0.5/'>10.0.5</option><option value='/10.0.4/'>10.0.4</option><option value='/10.0.3/'>10.0.3</option><option value='/10.0.2/'>10.0.2</option><option value='/10.0.1/'>10.0.1</option><option value='/10.0.0/'>10.0.0</option><option value='/9.0.19/'>9.0.19</option><option value='/9.0.18/'>9.0.18</option><option value='/9.0.17/'>9.0.17</option><option value='/9.0.16/'>9.0.16</option><option value='/9.0.15/'>9.0.15</option><option value='/9.0.14/'>9.0.14</option><option value='/9.0.13/'>9.0.13</option><option value='/9.0.12/'>9.0.12</option><option value='/9.0.11/'>9.0.11</option><option value='/9.0.10/'>9.0.10</option><option value='/9.0.9/'>9.0.9</option><option value='/9.0.8/'>9.0.8</option><option value='/9.0.7/'>9.0.7</option><option value='/9.0.6/'>9.0.6</option><option value='/9.0.5/'>9.0.5</option><option value='/9.0.4/'>9.0.4</option><option value='/9.0.3/'>9.0.3</option><option value='/9.0.2/'>9.0.2</option><option value='/9.0.1/'>9.0.1</option><option value='/9.0.0/'>9.0.0</option><option value='/1.0.2/'>1.0.2</option><option value='/1.0.1/'>1.0.1</option><option value='/1.0.0/'>1.0.0</option></select></li>");
}, 500);
</script>
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td id="projectlogo"><img alt="Logo" src="DPP-Logo.png"/></td>
<td style="padding-left: 0.5em;">
<div id="projectname">D++ (DPP)
</div>
<div id="projectbrief">C++ Discord API Bot Library</div>
</td>
</tr>
</tbody>
</table>
</div>
<!-- end header part -->
<label for="MSearchField" style="display: none">Search</label>
<!-- Generated by Doxygen 1.9.3 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt MIT */
var searchBox = new SearchBox("searchBox", "search",'Search','.html');
/* @license-end */
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt MIT */
$(function() {
initMenu('',true,false,'search.php','Search');
$(document).ready(function() { init_search(); });
});
/* @license-end */
</script>
<div id="main-nav"></div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
<div id="nav-tree">
<div id="nav-tree-contents">
<div id="nav-sync" class="sync"></div>
</div>
</div>
<div id="splitbar" style="-moz-user-select:none;"
class="ui-resizable-handle">
</div>
</div>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt MIT */
$(document).ready(function(){initNavTree('callback-functions.html',''); initResizable(); });
/* @license-end */
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
onmouseover="return searchBox.OnSearchSelectShow()"
onmouseout="return searchBox.OnSearchSelectHide()"
onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>
<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0"
name="MSearchResults" id="MSearchResults">
</iframe>
</div>
<div><div class="header">
<div class="headertitle"><div class="title">Using Callback Functions </div></div>
</div><!--header-->
<div class="contents">
<div class="textblock"><p >When you create or get an object from Discord, you send the request to its API and in return you get either an error or the object you requested/created. You can pass a function to API calls as the callback function. This means that when the request completes, and you get a response from the API, your callback function executes. You must be careful with lambda captures! Good practice would be not capturing variables by reference unless you have to, since when the request completes and the function executes, the variables can already be destructed. Advanced reference can be found <a href="https://dpp.dev/lambdas-and-locals.html">here</a>. Now, let's see callback functions in action:</p>
<div class="fragment"><div class="line"><span class="preprocessor">#include <dpp/dpp.h></span></div>
<div class="line"> </div>
<div class="line"><span class="keywordtype">int</span> main() {</div>
<div class="line"> <a class="code hl_class" href="classdpp_1_1cluster.html">dpp::cluster</a> bot(<span class="stringliteral">"Token Was Here"</span>, <a class="code hl_enumvalue" href="namespacedpp.html#a0042c0fc8164da4239b977d5be8e2ef5a561a52b3c6883808735c41891351c68f">dpp::i_default_intents</a> | <a class="code hl_enumvalue" href="namespacedpp.html#a0042c0fc8164da4239b977d5be8e2ef5a27810e825c157ded5d59df6dede23414">dpp::i_message_content</a>);</div>
<div class="line"> <span class="comment">/* the second argument is a bitmask of intents - i_message_content is needed to get messages */</span></div>
<div class="line"> </div>
<div class="line"> bot.on_log(<a class="code hl_function" href="namespacedpp_1_1utility.html#a8c2cc04bb80ffd287b376d5977899277">dpp::utility::cout_logger</a>());</div>
<div class="line"> </div>
<div class="line"> <span class="comment">/* The event is fired when someone issues your commands */</span></div>
<div class="line"> bot.on_slashcommand([&bot](<span class="keyword">const</span> <a class="code hl_struct" href="structdpp_1_1slashcommand__t.html">dpp::slashcommand_t</a>& event) {</div>
<div class="line"> <span class="keywordflow">if</span> (event.<a class="code hl_variable" href="structdpp_1_1interaction__create__t.html#a8b0c69c156a1e532507a918c13414f14">command</a>.<a class="code hl_function" href="classdpp_1_1interaction.html#aabbb8d58d708128098516ed443d5c140">get_command_name</a>() == <span class="stringliteral">"msgs-get"</span>) {</div>
<div class="line"> int64_t limit = std::get<int64_t>(event.get_parameter(<span class="stringliteral">"quantity"</span>));</div>
<div class="line"> </div>
<div class="line"> <span class="comment">/* get messages using ID of the channel the command was issued in */</span></div>
<div class="line"> bot.messages_get(event.command.channel_id, 0, 0, 0, limit, [event](const dpp::confirmation_callback_t& callback) {</div>
<div class="line"> if (callback.is_error()) { <span class="comment">/* catching an error to log it */</span></div>
<div class="line"> std::cout << callback.get_error().message << std::endl;</div>
<div class="line"> return;</div>
<div class="line"> }</div>
<div class="line"> </div>
<div class="line"> auto messages = callback.get<dpp::message_map>();</div>
<div class="line"> <span class="comment">/* std::get<dpp::message_map>(callback.value) would give the same result */</span></div>
<div class="line"> </div>
<div class="line"> std::string contents;</div>
<div class="line"> for (const auto& x : messages) { <span class="comment">/* here we iterate through the dpp::message_map we got from callback... */</span></div>
<div class="line"> contents += x.second.content + <span class="stringliteral">'\n'</span>; <span class="comment">/* ...where x.first is ID of the current message and x.second is the message itself. */</span></div>
<div class="line"> }</div>
<div class="line"> </div>
<div class="line"> event.reply(contents); <span class="comment">/* we will see all those messages we got, united as one! */</span></div>
<div class="line"> });</div>
<div class="line"> } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (event.<a class="code hl_variable" href="structdpp_1_1interaction__create__t.html#a8b0c69c156a1e532507a918c13414f14">command</a>.<a class="code hl_function" href="classdpp_1_1interaction.html#aabbb8d58d708128098516ed443d5c140">get_command_name</a>() == <span class="stringliteral">"channel-create"</span>) {</div>
<div class="line"> <span class="comment">/* create a text channel */</span></div>
<div class="line"> <a class="code hl_class" href="classdpp_1_1channel.html">dpp::channel</a> channel = <a class="code hl_class" href="classdpp_1_1channel.html">dpp::channel</a>()</div>
<div class="line"> .<a class="code hl_function" href="classdpp_1_1channel.html#a304e19817c6bf0e363daf497a3011f3a">set_name</a>(<span class="stringliteral">"test"</span>)</div>
<div class="line"> .<a class="code hl_function" href="classdpp_1_1channel.html#aa823c3a070bc37d70be28bd9b49820c5">set_guild_id</a>(event.<a class="code hl_variable" href="structdpp_1_1interaction__create__t.html#a8b0c69c156a1e532507a918c13414f14">command</a>.<a class="code hl_variable" href="classdpp_1_1interaction.html#a6301d14a86e9b51b656ef589c2e39009">guild_id</a>);</div>
<div class="line"> </div>
<div class="line"> bot.channel_create(channel, [&bot, event](<span class="keyword">const</span> <a class="code hl_struct" href="structdpp_1_1confirmation__callback__t.html">dpp::confirmation_callback_t</a>& callback) -> <span class="keywordtype">void</span> {</div>
<div class="line"> <span class="keywordflow">if</span> (callback.<a class="code hl_function" href="structdpp_1_1confirmation__callback__t.html#a17820d5f9fb0725d64a1bf23c8cc97c7">is_error</a>()) { <span class="comment">/* catching an error to log it */</span></div>
<div class="line"> bot.log(dpp::loglevel::ll_error, callback.get_error().message);</div>
<div class="line"> return;</div>
<div class="line"> }</div>
<div class="line"> </div>
<div class="line"> <span class="keyword">auto</span> channel = callback.<a class="code hl_function" href="structdpp_1_1confirmation__callback__t.html#ac32b677abe27aa496063ee34a4ae1fbd">get</a><<a class="code hl_class" href="classdpp_1_1channel.html">dpp::channel</a>>();</div>
<div class="line"> <span class="comment">/* std::get<dpp::channel>(callback.value) would give the same result */</span></div>
<div class="line"> </div>
<div class="line"> <span class="comment">/* reply with the created channel information */</span></div>
<div class="line"> <a class="code hl_struct" href="structdpp_1_1message.html">dpp::message</a> message = <a class="code hl_struct" href="structdpp_1_1message.html">dpp::message</a>(<span class="stringliteral">"The channel's name is `"</span> + channel.<a class="code hl_variable" href="classdpp_1_1channel.html#a065d6fbd4e21759354c2516b074078a8">name</a> + <span class="stringliteral">"`, ID is `"</span> + std::to_string(channel.<a class="code hl_variable" href="classdpp_1_1managed.html#a40bf0c6cc03909910512808fa6caa112">id</a>) + <span class="stringliteral">" and type is `"</span> + std::to_string(channel.<a class="code hl_function" href="classdpp_1_1channel.html#a8095c887b1cb49c81b9d3044da51955c">get_type</a>()) + <span class="stringliteral">"`."</span>);</div>
<div class="line"> <span class="comment">/* note that channel types are represented as numbers */</span></div>
<div class="line"> event.<a class="code hl_function" href="structdpp_1_1interaction__create__t.html#a34f374b358f8d2d49fa93bfe5a2c0493">reply</a>(message);</div>
<div class="line"> });</div>
<div class="line"> } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (event.<a class="code hl_variable" href="structdpp_1_1interaction__create__t.html#a8b0c69c156a1e532507a918c13414f14">command</a>.<a class="code hl_function" href="classdpp_1_1interaction.html#aabbb8d58d708128098516ed443d5c140">get_command_name</a>() == <span class="stringliteral">"msg-error"</span>) {</div>
<div class="line"> bot.message_get(0, 0, [event](<span class="keyword">const</span> <a class="code hl_struct" href="structdpp_1_1confirmation__callback__t.html">dpp::confirmation_callback_t</a>& callback) -> <span class="keywordtype">void</span> {</div>
<div class="line"> <span class="comment">/* the error will occur since there is no message with ID '0' that is in a channel with ID '0' (I'm not explaining why) */</span></div>
<div class="line"> <span class="keywordflow">if</span> (callback.<a class="code hl_function" href="structdpp_1_1confirmation__callback__t.html#a17820d5f9fb0725d64a1bf23c8cc97c7">is_error</a>()) {</div>
<div class="line"> event.reply(callback.get_error().message);</div>
<div class="line"> return;</div>
<div class="line"> }</div>
<div class="line"> </div>
<div class="line"> <span class="comment">/* we won't be able to get here because of the return; statement */</span></div>
<div class="line"> <span class="keyword">auto</span> message = callback.<a class="code hl_function" href="structdpp_1_1confirmation__callback__t.html#ac32b677abe27aa496063ee34a4ae1fbd">get</a><<a class="code hl_struct" href="structdpp_1_1message.html">dpp::message</a>>();</div>
<div class="line"> event.<a class="code hl_function" href="structdpp_1_1interaction__create__t.html#a34f374b358f8d2d49fa93bfe5a2c0493">reply</a>(message);</div>
<div class="line"> });</div>
<div class="line"> }</div>
<div class="line"> });</div>
<div class="line"> </div>
<div class="line"> bot.on_ready([&bot](<span class="keyword">const</span> <a class="code hl_struct" href="structdpp_1_1ready__t.html">dpp::ready_t</a>& event) {</div>
<div class="line"> <span class="keywordflow">if</span> (dpp::run_once <struct register_global_commands>()) {</div>
<div class="line"> <a class="code hl_class" href="classdpp_1_1slashcommand.html">dpp::slashcommand</a> msgs_get(<span class="stringliteral">"msgs-get"</span>, <span class="stringliteral">"Get messages"</span>, bot.me.id);</div>
<div class="line"> </div>
<div class="line"> <span class="keyword">constexpr</span> int64_t min_val{1};</div>
<div class="line"> <span class="keyword">constexpr</span> int64_t max_val{100};</div>
<div class="line"> </div>
<div class="line"> msgs_get.add_option(</div>
<div class="line"> <a class="code hl_struct" href="structdpp_1_1command__option.html">dpp::command_option</a>(<a class="code hl_enumvalue" href="namespacedpp.html#abc401d86119c6443bf72d736857c1a58a7e18bae49699df4948c28c12bfa8bd19">dpp::co_integer</a>, <span class="stringliteral">"quantity"</span>, <span class="stringliteral">"Quantity of messages to get. Max - 100."</span>)</div>
<div class="line"> .set_min_value(min_val)</div>
<div class="line"> .set_max_value(max_val)</div>
<div class="line"> );</div>
<div class="line"> </div>
<div class="line"> <a class="code hl_class" href="classdpp_1_1slashcommand.html">dpp::slashcommand</a> channel_create(<span class="stringliteral">"channel-create"</span>, <span class="stringliteral">"Create a channel"</span>, bot.me.id);</div>
<div class="line"> <a class="code hl_class" href="classdpp_1_1slashcommand.html">dpp::slashcommand</a> msg_error(<span class="stringliteral">"msg-error"</span>, <span class="stringliteral">"Get an error instead of message :)"</span>, bot.me.id);</div>
<div class="line"> </div>
<div class="line"> bot.global_bulk_command_create({ msgs_get, channel_create, msg_error });</div>
<div class="line"> }</div>
<div class="line"> });</div>
<div class="line"> </div>
<div class="line"> bot.start(<a class="code hl_enumvalue" href="namespacedpp.html#af447e04d0490cd4a9de085e4a758faa4a155f7db65696b4c09b5fcc41787e4726">dpp::st_wait</a>);</div>
<div class="line"> </div>
<div class="line"> <span class="keywordflow">return</span> 0;</div>
<div class="line">}</div>
<div class="ttc" id="aclassdpp_1_1channel_html"><div class="ttname"><a href="classdpp_1_1channel.html">dpp::channel</a></div><div class="ttdoc">A definition of a discord channel. There are one of these for every channel type except threads....</div><div class="ttdef"><b>Definition:</b> channel.h:340</div></div>
<div class="ttc" id="aclassdpp_1_1channel_html_a065d6fbd4e21759354c2516b074078a8"><div class="ttname"><a href="classdpp_1_1channel.html#a065d6fbd4e21759354c2516b074078a8">dpp::channel::name</a></div><div class="ttdeci">std::string name</div><div class="ttdoc">Channel name (1-100 characters).</div><div class="ttdef"><b>Definition:</b> channel.h:364</div></div>
<div class="ttc" id="aclassdpp_1_1channel_html_a304e19817c6bf0e363daf497a3011f3a"><div class="ttname"><a href="classdpp_1_1channel.html#a304e19817c6bf0e363daf497a3011f3a">dpp::channel::set_name</a></div><div class="ttdeci">channel & set_name(const std::string &name)</div><div class="ttdoc">Set name of this channel object.</div></div>
<div class="ttc" id="aclassdpp_1_1channel_html_a8095c887b1cb49c81b9d3044da51955c"><div class="ttname"><a href="classdpp_1_1channel.html#a8095c887b1cb49c81b9d3044da51955c">dpp::channel::get_type</a></div><div class="ttdeci">channel_type get_type() const</div><div class="ttdoc">Get the channel type.</div></div>
<div class="ttc" id="aclassdpp_1_1channel_html_aa823c3a070bc37d70be28bd9b49820c5"><div class="ttname"><a href="classdpp_1_1channel.html#aa823c3a070bc37d70be28bd9b49820c5">dpp::channel::set_guild_id</a></div><div class="ttdeci">channel & set_guild_id(const snowflake guild_id)</div><div class="ttdoc">Set guild_id of this channel object.</div></div>
<div class="ttc" id="aclassdpp_1_1cluster_html"><div class="ttname"><a href="classdpp_1_1cluster.html">dpp::cluster</a></div><div class="ttdoc">The cluster class represents a group of shards and a command queue for sending and receiving commands...</div><div class="ttdef"><b>Definition:</b> cluster.h:80</div></div>
<div class="ttc" id="aclassdpp_1_1interaction_html_a6301d14a86e9b51b656ef589c2e39009"><div class="ttname"><a href="classdpp_1_1interaction.html#a6301d14a86e9b51b656ef589c2e39009">dpp::interaction::guild_id</a></div><div class="ttdeci">snowflake guild_id</div><div class="ttdoc">Optional: the guild it was sent from.</div><div class="ttdef"><b>Definition:</b> appcommand.h:1004</div></div>
<div class="ttc" id="aclassdpp_1_1interaction_html_aabbb8d58d708128098516ed443d5c140"><div class="ttname"><a href="classdpp_1_1interaction.html#aabbb8d58d708128098516ed443d5c140">dpp::interaction::get_command_name</a></div><div class="ttdeci">std::string get_command_name() const</div><div class="ttdoc">Get the command name for a command interaction.</div></div>
<div class="ttc" id="aclassdpp_1_1managed_html_a40bf0c6cc03909910512808fa6caa112"><div class="ttname"><a href="classdpp_1_1managed.html#a40bf0c6cc03909910512808fa6caa112">dpp::managed::id</a></div><div class="ttdeci">snowflake id</div><div class="ttdoc">Unique ID of object set by Discord. This value contains a timestamp, worker ID, internal server ID,...</div><div class="ttdef"><b>Definition:</b> managed.h:39</div></div>
<div class="ttc" id="aclassdpp_1_1slashcommand_html"><div class="ttname"><a href="classdpp_1_1slashcommand.html">dpp::slashcommand</a></div><div class="ttdoc">Represents an application command, created by your bot either globally, or on a guild.</div><div class="ttdef"><b>Definition:</b> appcommand.h:1397</div></div>
<div class="ttc" id="anamespacedpp_1_1utility_html_a8c2cc04bb80ffd287b376d5977899277"><div class="ttname"><a href="namespacedpp_1_1utility.html#a8c2cc04bb80ffd287b376d5977899277">dpp::utility::cout_logger</a></div><div class="ttdeci">std::function< void(const dpp::log_t &)> DPP_EXPORT cout_logger()</div><div class="ttdoc">Get a default logger that outputs to std::cout. e.g.</div></div>
<div class="ttc" id="anamespacedpp_html_a0042c0fc8164da4239b977d5be8e2ef5a27810e825c157ded5d59df6dede23414"><div class="ttname"><a href="namespacedpp.html#a0042c0fc8164da4239b977d5be8e2ef5a27810e825c157ded5d59df6dede23414">dpp::i_message_content</a></div><div class="ttdeci">@ i_message_content</div><div class="ttdoc">Intent for receipt of message content.</div><div class="ttdef"><b>Definition:</b> intents.h:112</div></div>
<div class="ttc" id="anamespacedpp_html_a0042c0fc8164da4239b977d5be8e2ef5a561a52b3c6883808735c41891351c68f"><div class="ttname"><a href="namespacedpp.html#a0042c0fc8164da4239b977d5be8e2ef5a561a52b3c6883808735c41891351c68f">dpp::i_default_intents</a></div><div class="ttdeci">@ i_default_intents</div><div class="ttdoc">Default D++ intents (all non-privileged intents).</div><div class="ttdef"><b>Definition:</b> intents.h:132</div></div>
<div class="ttc" id="anamespacedpp_html_abc401d86119c6443bf72d736857c1a58a7e18bae49699df4948c28c12bfa8bd19"><div class="ttname"><a href="namespacedpp.html#abc401d86119c6443bf72d736857c1a58a7e18bae49699df4948c28c12bfa8bd19">dpp::co_integer</a></div><div class="ttdeci">@ co_integer</div><div class="ttdoc">An integer value.</div><div class="ttdef"><b>Definition:</b> appcommand.h:70</div></div>
<div class="ttc" id="anamespacedpp_html_af447e04d0490cd4a9de085e4a758faa4a155f7db65696b4c09b5fcc41787e4726"><div class="ttname"><a href="namespacedpp.html#af447e04d0490cd4a9de085e4a758faa4a155f7db65696b4c09b5fcc41787e4726">dpp::st_wait</a></div><div class="ttdeci">@ st_wait</div><div class="ttdoc">Wait forever on a condition variable. The cluster will spawn threads for each shard and start() will ...</div><div class="ttdef"><b>Definition:</b> cluster.h:63</div></div>
<div class="ttc" id="astructdpp_1_1command__option_html"><div class="ttname"><a href="structdpp_1_1command__option.html">dpp::command_option</a></div><div class="ttdoc">Each command option is a command line parameter. It can have a type (see dpp::command_option_type),...</div><div class="ttdef"><b>Definition:</b> appcommand.h:204</div></div>
<div class="ttc" id="astructdpp_1_1confirmation__callback__t_html"><div class="ttname"><a href="structdpp_1_1confirmation__callback__t.html">dpp::confirmation_callback_t</a></div><div class="ttdoc">The results of a REST call wrapped in a convenient struct.</div><div class="ttdef"><b>Definition:</b> restresults.h:256</div></div>
<div class="ttc" id="astructdpp_1_1confirmation__callback__t_html_a17820d5f9fb0725d64a1bf23c8cc97c7"><div class="ttname"><a href="structdpp_1_1confirmation__callback__t.html#a17820d5f9fb0725d64a1bf23c8cc97c7">dpp::confirmation_callback_t::is_error</a></div><div class="ttdeci">bool is_error() const</div><div class="ttdoc">Returns true if the call resulted in an error rather than a legitimate value in the confirmation_call...</div></div>
<div class="ttc" id="astructdpp_1_1confirmation__callback__t_html_ac32b677abe27aa496063ee34a4ae1fbd"><div class="ttname"><a href="structdpp_1_1confirmation__callback__t.html#ac32b677abe27aa496063ee34a4ae1fbd">dpp::confirmation_callback_t::get</a></div><div class="ttdeci">T get() const</div><div class="ttdoc">Get the stored value via std::get.</div><div class="ttdef"><b>Definition:</b> restresults.h:324</div></div>
<div class="ttc" id="astructdpp_1_1interaction__create__t_html_a34f374b358f8d2d49fa93bfe5a2c0493"><div class="ttname"><a href="structdpp_1_1interaction__create__t.html#a34f374b358f8d2d49fa93bfe5a2c0493">dpp::interaction_create_t::reply</a></div><div class="ttdeci">void reply(command_completion_event_t callback=utility::log_error()) const</div><div class="ttdoc">Acknowledge interaction without displaying a message to the user, for use with button and select menu...</div></div>
<div class="ttc" id="astructdpp_1_1interaction__create__t_html_a8b0c69c156a1e532507a918c13414f14"><div class="ttname"><a href="structdpp_1_1interaction__create__t.html#a8b0c69c156a1e532507a918c13414f14">dpp::interaction_create_t::command</a></div><div class="ttdeci">interaction command</div><div class="ttdoc">command interaction</div><div class="ttdef"><b>Definition:</b> dispatcher.h:678</div></div>
<div class="ttc" id="astructdpp_1_1message_html"><div class="ttname"><a href="structdpp_1_1message.html">dpp::message</a></div><div class="ttdoc">Represents messages sent and received on Discord.</div><div class="ttdef"><b>Definition:</b> message.h:2071</div></div>
<div class="ttc" id="astructdpp_1_1ready__t_html"><div class="ttname"><a href="structdpp_1_1ready__t.html">dpp::ready_t</a></div><div class="ttdoc">Session ready.</div><div class="ttdef"><b>Definition:</b> dispatcher.h:961</div></div>
<div class="ttc" id="astructdpp_1_1slashcommand__t_html"><div class="ttname"><a href="structdpp_1_1slashcommand__t.html">dpp::slashcommand_t</a></div><div class="ttdoc">User has issued a slash command.</div><div class="ttdef"><b>Definition:</b> dispatcher.h:695</div></div>
</div><!-- fragment --><p >This is the result:</p>
<div class="image">
<img src="callback_functions.png" alt=""/>
</div>
</div></div><!-- contents --><script src="https://giscus.app/client.js" data-repo="brainboxdotcc/dpp-comments" data-repo-id="R_kgDOHOY4xg" data-category="General" data-category-id="DIC_kwDOHOY4xs4CRYtj" data-mapping="pathname" data-strict="1" data-reactions-enabled="1" data-emit-metadata="1" data-input-position="top" data-theme="preferred_color_scheme" data-lang="en" data-loading="lazy" crossorigin="anonymous" async></script>
</div><!-- PageDoc -->
</div><!-- doc-content -->
<div id="nav-path" class="navpath">
<ul>
<li class="navelem"><a class="el" href="example-programs.html">Example Programs</a></li><li class="navelem"><a class="el" href="the-basics.html">The Basics</a></li>
</ul>
</div>
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-QTH6YHBNG5"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.6.0/styles/base16/dracula.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.6.0/highlight.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlightjs-line-numbers.js/2.8.0/highlightjs-line-numbers.min.js"></script>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@100&display=swap" rel="stylesheet">
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-QTH6YHBNG5');
$(function() {
$(".fragment").each(function(i,node) {
var $node = $(node);
$node.children(":not(.line)").remove();
$node.html("<pre><code class='stan'>" + $node.text().trim().replaceAll("<", "<").replaceAll(">", ">") + "</code></pre>");
hljs.configure({
languages: ['cpp','diff','cmake','bash','sh','text'],
ignoreUnescapedHTML: true
});
hljs.highlightAll(node);
hljs.initLineNumbersOnLoad(node);
});
$(".fragment").parent().parent().parent().parent().removeClass('doxtable');
});
</script>
<style>
.hljs-ln-code, code, code a, pre.fragment, div.fragment, div.fragment .line, div.fragment span, div.fragment .line a, div.fragment .line span {
font-family: 'JetBrains Mono', monospace !important;
font-size: 0.8rem !important;
}
.fragment {
padding: 0 !important;
margin-top: 0 !important;
margin-bottom: 0 !important;
background: none !important;
border: 0 !important;
}
.hljs-ln-n::before {
content: attr(data-line-number);
padding-right: 1rem !important;
}
table.markdownTable code td, table.markdownTable code th, table.fieldtable code td, table.fieldtable code th, table.doxtable code td, table.doxtable code th {
border: 0 !important;
padding: 0 !important;
}
</style>
<div style="z-index: -9999; position: absolute; right: 0; top: 0; font-size: 0.0001rem;color:transparent;background:none">
<!-- For crawlability of past versions -->
<a href='/10.0.35/'>D++ Library version 10.0.35</a><a href='/10.0.34/'>D++ Library version 10.0.34</a><a href='/10.0.33/'>D++ Library version 10.0.33</a><a href='/10.0.32/'>D++ Library version 10.0.32</a><a href='/10.0.31/'>D++ Library version 10.0.31</a><a href='/10.0.30/'>D++ Library version 10.0.30</a><a href='/10.0.29/'>D++ Library version 10.0.29</a><a href='/10.0.28/'>D++ Library version 10.0.28</a><a href='/10.0.27/'>D++ Library version 10.0.27</a><a href='/10.0.26/'>D++ Library version 10.0.26</a><a href='/10.0.25/'>D++ Library version 10.0.25</a><a href='/10.0.24/'>D++ Library version 10.0.24</a><a href='/10.0.23/'>D++ Library version 10.0.23</a><a href='/10.0.22/'>D++ Library version 10.0.22</a><a href='/10.0.21/'>D++ Library version 10.0.21</a><a href='/10.0.20/'>D++ Library version 10.0.20</a><a href='/10.0.19/'>D++ Library version 10.0.19</a><a href='/10.0.18/'>D++ Library version 10.0.18</a><a href='/10.0.17/'>D++ Library version 10.0.17</a><a href='/10.0.16/'>D++ Library version 10.0.16</a><a href='/10.0.15/'>D++ Library version 10.0.15</a><a href='/10.0.14/'>D++ Library version 10.0.14</a><a href='/10.0.13/'>D++ Library version 10.0.13</a><a href='/10.0.12/'>D++ Library version 10.0.12</a><a href='/10.0.11/'>D++ Library version 10.0.11</a><a href='/10.0.10/'>D++ Library version 10.0.10</a><a href='/10.0.9/'>D++ Library version 10.0.9</a><a href='/10.0.8/'>D++ Library version 10.0.8</a><a href='/10.0.7/'>D++ Library version 10.0.7</a><a href='/10.0.6/'>D++ Library version 10.0.6</a><a href='/10.0.5/'>D++ Library version 10.0.5</a><a href='/10.0.4/'>D++ Library version 10.0.4</a><a href='/10.0.3/'>D++ Library version 10.0.3</a><a href='/10.0.2/'>D++ Library version 10.0.2</a><a href='/10.0.1/'>D++ Library version 10.0.1</a><a href='/10.0.0/'>D++ Library version 10.0.0</a><a href='/9.0.19/'>D++ Library version 9.0.19</a><a href='/9.0.18/'>D++ Library version 9.0.18</a><a href='/9.0.17/'>D++ Library version 9.0.17</a><a href='/9.0.16/'>D++ Library version 9.0.16</a><a href='/9.0.15/'>D++ Library version 9.0.15</a><a href='/9.0.14/'>D++ Library version 9.0.14</a><a href='/9.0.13/'>D++ Library version 9.0.13</a><a href='/9.0.12/'>D++ Library version 9.0.12</a><a href='/9.0.11/'>D++ Library version 9.0.11</a><a href='/9.0.10/'>D++ Library version 9.0.10</a><a href='/9.0.9/'>D++ Library version 9.0.9</a><a href='/9.0.8/'>D++ Library version 9.0.8</a><a href='/9.0.7/'>D++ Library version 9.0.7</a><a href='/9.0.6/'>D++ Library version 9.0.6</a><a href='/9.0.5/'>D++ Library version 9.0.5</a><a href='/9.0.4/'>D++ Library version 9.0.4</a><a href='/9.0.3/'>D++ Library version 9.0.3</a><a href='/9.0.2/'>D++ Library version 9.0.2</a><a href='/9.0.1/'>D++ Library version 9.0.1</a><a href='/9.0.0/'>D++ Library version 9.0.0</a><a href='/1.0.2/'>D++ Library version 1.0.2</a><a href='/1.0.1/'>D++ Library version 1.0.1</a><a href='/1.0.0/'>D++ Library version 1.0.0</a>
</div>
</body>
</html>