Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(breaking): 10.1 - socket engines, refactor, remove dpp::sync #1334

Merged
merged 118 commits into from
Dec 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
118 commits
Select commit Hold shift + click to select a range
eb5d05b
socket engine basics
braindigitalis Apr 3, 2024
9566009
epoll and kqueue stuff
braindigitalis Apr 4, 2024
0162754
poll class
braindigitalis Apr 4, 2024
d1fcd83
make this default to the hint size not 16
braindigitalis Apr 4, 2024
3f216b3
socktest
braindigitalis Apr 4, 2024
4a7bceb
poll
braindigitalis Apr 4, 2024
1b91824
includes
braindigitalis Apr 4, 2024
a1e96f1
getsockopt
braindigitalis Apr 4, 2024
7c4ee46
kqueue fixes
braindigitalis Apr 4, 2024
a0cc158
kqueue fixes
braindigitalis Apr 4, 2024
62306af
move se stuff into dpp namespace
braindigitalis Apr 4, 2024
7571319
missing name
braindigitalis Apr 4, 2024
0cbb698
Merge branch 'dev' of github.com:brainboxdotcc/DPP into socketengine
braindigitalis Sep 24, 2024
b63492f
feat: thread pool object
braindigitalis Sep 24, 2024
7ba4f78
fix: forgot to change this include when moving source over
braindigitalis Sep 24, 2024
b2f9ecd
merge
braindigitalis Nov 11, 2024
22bcdda
feat: socket engine thread pool
braindigitalis Nov 11, 2024
8ce80b2
document socket_engine_base
braindigitalis Nov 11, 2024
1c434a8
unistd.h is required
braindigitalis Nov 11, 2024
910ded2
[skip ci] working sslclient - full of debug, needs properly integrati…
braindigitalis Nov 13, 2024
406642e
[skip ci] fix test program
braindigitalis Nov 13, 2024
9cc64ad
[skip ci] fix test program
braindigitalis Nov 13, 2024
c6278eb
[skip ci] i love to break stuff
braindigitalis Nov 13, 2024
a742604
priority queue
braindigitalis Nov 14, 2024
3ad1762
[skip ci] https client/queues migration to socketengine
braindigitalis Nov 15, 2024
f479209
[skip ci] fixes
braindigitalis Nov 15, 2024
6e9fa8d
[skip ci] no longer any need for out_queue -> goes into the main thre…
braindigitalis Nov 15, 2024
3917ec7
thread pooled events
braindigitalis Nov 15, 2024
67dc0b7
put websocket events into the work queue
braindigitalis Nov 16, 2024
2c3e701
make poll ctor not protected
braindigitalis Nov 16, 2024
7994a4a
unit test no longer runs forever
braindigitalis Nov 16, 2024
9c2e71d
fix some httpsclient stuff
braindigitalis Nov 16, 2024
d286958
remove jthread, c++20 only
braindigitalis Nov 16, 2024
f76f2d1
terminating.notify_all is C++20
braindigitalis Nov 16, 2024
f53a582
sleep() shouldnt be used, instead use std::this_thread::sleep_for(std…
braindigitalis Nov 16, 2024
057db5e
dont let request_verb go out of scope
braindigitalis Nov 16, 2024
4b59c65
always populate even on timeout
braindigitalis Nov 16, 2024
b0c3b3c
some unit tests improvements
braindigitalis Nov 16, 2024
d4a3195
Merge branch 'dev' of github.com:brainboxdotcc/DPP into socketengine
braindigitalis Nov 16, 2024
80144d1
fix role edit/role delete unit tests
braindigitalis Nov 16, 2024
5ae9b8b
some codacy fixes
braindigitalis Nov 17, 2024
192b8ae
fix http(s) requests with 0 content length timing out
braindigitalis Nov 17, 2024
c34c2d8
errors were missing part of the url
braindigitalis Nov 17, 2024
8542b08
fix: add auto retry to failed connect, fixes failed unit tests
braindigitalis Nov 18, 2024
1169268
remove dpp::sync from unit tests, we no longer test it
braindigitalis Nov 18, 2024
dc8bb5d
fix kqueue to actually work on freebsd
braindigitalis Nov 19, 2024
2dc084a
kqueue tidyup
braindigitalis Nov 19, 2024
e3e8870
sanity checks
braindigitalis Nov 19, 2024
d9b82a4
safety check handlers
braindigitalis Nov 19, 2024
366f2dc
add prune
braindigitalis Nov 19, 2024
a819c5f
error handling
braindigitalis Nov 19, 2024
23cf123
error handling
braindigitalis Nov 19, 2024
a2a21c9
mutexing of timer list
braindigitalis Nov 19, 2024
6a36514
dont resize the ke_list
braindigitalis Nov 19, 2024
276e2ff
fixes for cluster destructor on freebsd
braindigitalis Nov 19, 2024
317717e
destroy thread for socket loop before trying to destroy anything that…
braindigitalis Nov 19, 2024
2125d1b
Merge branch 'dev' of github.com:brainboxdotcc/DPP into socketengine
braindigitalis Nov 20, 2024
93fc814
fixes for poll on windows
braindigitalis Nov 20, 2024
d119a3b
[skip ci] we dont need to check for epoll removal failure, if it fail…
braindigitalis Nov 20, 2024
f80a975
properly mutex everything
braindigitalis Nov 21, 2024
e9ef7a7
improve threading
braindigitalis Nov 21, 2024
0114e14
[skip ci] fix typo in kqueue
braindigitalis Nov 21, 2024
8bf9b8c
[skip ci] warning fixes
braindigitalis Nov 21, 2024
2dbcb65
fix: these things shouldnt throw
braindigitalis Nov 22, 2024
d22254b
feat: error handling and client auto reconnect
braindigitalis Nov 22, 2024
fda53d4
ci: force pkgconf unlink for brew
Jaskowicz1 Nov 23, 2024
2b7f7f3
ci: removed pkg-config from brew as no longer needed
Jaskowicz1 Nov 23, 2024
246f2d7
ci: macos version will now always be 15
Jaskowicz1 Nov 23, 2024
dc4cf95
refactor: remove nonblocking bool, as all sockets are always now nonb…
braindigitalis Nov 23, 2024
8889aa9
Merge branch 'socketengine' of github.com:brainboxdotcc/DPP into sock…
braindigitalis Nov 23, 2024
a548c2c
audio isnt being heard, dont know why yet
braindigitalis Nov 25, 2024
f21c6b9
audio works if user joins 2nd
braindigitalis Nov 25, 2024
6830a83
Fix/voice socketengine (#1337)
Neko-Life Nov 27, 2024
c26defc
fix: SE shadows variable
braindigitalis Nov 27, 2024
f2d5cfd
refactor: remove thread pool from request queue, run it off dpp::time…
braindigitalis Nov 27, 2024
70c0ba3
fix: now compiles with voice disabled
braindigitalis Nov 27, 2024
7ce5182
fix: macos CI
braindigitalis Nov 27, 2024
feee595
docs: redo thread model dot
braindigitalis Nov 27, 2024
4d9fbbf
fix/sslclient-spinlock (#1339)
Neko-Life Dec 1, 2024
e1d0ab8
fix: reconnect of shards
braindigitalis Dec 1, 2024
b9e2ace
Merge branch 'dev' of github.com:brainboxdotcc/DPP into socketengine
braindigitalis Dec 1, 2024
315046c
tidy up shard startup
braindigitalis Dec 2, 2024
f2e1edc
voice session reconnect
braindigitalis Dec 2, 2024
8c0c5d2
fix: prevent concurrent on_disconnect()
braindigitalis Dec 3, 2024
5f5489e
refactor: magic numbers in discordclient
braindigitalis Dec 3, 2024
f584b2f
catch exceptions on reconnect
braindigitalis Dec 3, 2024
7ae853e
fix: locking primitives
braindigitalis Dec 3, 2024
8b83af2
refactor: eliminate raw pointers from timer code
braindigitalis Dec 3, 2024
e6f0d50
feat: improved timer system, fix for runaway cpu usage due to connect…
braindigitalis Dec 4, 2024
6a76049
fix: segfault when calling read on an invalid fd
braindigitalis Dec 4, 2024
0d5e932
fix: https request queues still need a removals queue, it can be simp…
braindigitalis Dec 4, 2024
4edc9a2
fix: apple weirdness
braindigitalis Dec 4, 2024
b01da99
docs: document various new functions [skip ci]
braindigitalis Dec 5, 2024
a8b006b
[skip ci] adjust version to 10.1
braindigitalis Dec 6, 2024
e2771ad
fix reconnection of shards by creating new shards on reconnect, with …
braindigitalis Dec 7, 2024
9d3fbb2
fix reconnect on timeout
braindigitalis Dec 9, 2024
f3b85a4
fix: check for events on invalid sockets
braindigitalis Dec 9, 2024
6e87030
call on_disconnect in more situations so we can properly handle dead …
braindigitalis Dec 10, 2024
edcefd6
fix: ensure heirarchy correctly calls the various inherited functions…
braindigitalis Dec 10, 2024
587a51b
fix: don't store the event ptrs in the kevent/epoll udata, this can e…
braindigitalis Dec 11, 2024
5a06ebc
fix: immediately delete fds that want deletion after we are done firi…
braindigitalis Dec 12, 2024
4ee7abb
fix: use exceptions to bail out of parseheader
braindigitalis Dec 12, 2024
ae0565c
fix: missing boolean
braindigitalis Dec 12, 2024
c3b5257
tidy up casting in decompression code
braindigitalis Dec 12, 2024
438f9a4
move some things into constexpr constants
braindigitalis Dec 13, 2024
3119752
refactor: make overridden sslclient stuff have override keyword, tidy…
braindigitalis Dec 13, 2024
31594f1
split out zlib stuff to its own file
braindigitalis Dec 13, 2024
adb25d1
refactor: remove raw pointers from dns code
braindigitalis Dec 13, 2024
686344a
fix: unique_ptr on g++-8 needs to know sizeof() z_stream up front, so…
braindigitalis Dec 13, 2024
1cd4de9
docs: new webhook example
braindigitalis Dec 13, 2024
549abc8
refactor: remove dpp::sync
braindigitalis Dec 13, 2024
2c18366
refactor: remove sync.h
braindigitalis Dec 13, 2024
aba8aef
refactor: remove some deprecated and unused fields
braindigitalis Dec 13, 2024
06113a4
fix; when putting events into the thread pool work queue, we must tak…
braindigitalis Dec 13, 2024
2190cf6
make event.from safe in threads
braindigitalis Dec 14, 2024
cbdc1f9
fix(docs): update documentation examples to use event.from() and even…
braindigitalis Dec 14, 2024
786b1dd
docs: missing comment blocks
braindigitalis Dec 14, 2024
56694b2
fix: make new constructor for cluster explicit
braindigitalis Dec 14, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .clang-tidy
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# TODO: Discuss about -readability-identifier-length, -readability-avoid-const-params-in-decls
Checks: "-*,bugprone-*,cert-*,clang-analyzer-*,concurrency-*,cppcoreguidelines-*,llvm-namespace-comment,modernize-*,performance-*,portability-*,readability-*,-bugprone-implicit-widening-of-multiplication-result, -bugprone-easily-swappable-parameters,-readability-identifier-length,-portability-restrict-system-includes,-modernize-use-trailing-return-type,-cppcoreguidelines-non-private-member-variables-in-classes,-readability-avoid-const-params-in-decls"
Checks: "-*,bugprone-*,cert-*,clang-analyzer-*,concurrency-*,cppcoreguidelines-*,llvm-namespace-comment,modernize-*,performance-*,portability-*,readability-*,-bugprone-implicit-widening-of-multiplication-result,-bugprone-easily-swappable-parameters,-readability-identifier-length,-portability-restrict-system-includes,-modernize-use-trailing-return-type,-cppcoreguidelines-non-private-member-variables-in-classes,-readability-avoid-const-params-in-decls,-cppcoreguidelines-owning-memory,-readability-function-cognitive-complexity,-cppcoreguidelines-avoid-do-while"
3 changes: 3 additions & 0 deletions .cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
"version": "0.2",
"language": "en-GB",
"words": [
"EVFILT",
"fflags",
"udata",
"blurple",
"featurable",
"libdpp",
Expand Down
4 changes: 2 additions & 2 deletions buildtools/classes/Generator/CoroGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public function getCommentArray(): array
*/
public function saveHeader(string $content): void
{
$content .= "[[nodiscard]] async<http_request_completion_t> co_request(const std::string &url, http_method method, const std::string &postdata = \"\", const std::string &mimetype = \"text/plain\", const std::multimap<std::string, std::string> &headers = {}, const std::string &protocol = \"1.1\", time_t request_timeout = 5);\n\n";
$content .= "[[nodiscard]] async<http_request_completion_t> co_request(const std::string &url, http_method method, const std::string &postdata = \"\", const std::string &mimetype = \"text/plain\", const std::multimap<std::string, std::string> &headers = {}, const std::string &protocol = \"1.1\");\n\n";
file_put_contents('include/dpp/cluster_coro_calls.h', $content);
}

Expand All @@ -125,7 +125,7 @@ public function saveHeader(string $content): void
*/
public function saveCpp(string $cppcontent): void
{
$cppcontent .= "dpp::async<dpp::http_request_completion_t> dpp::cluster::co_request(const std::string &url, http_method method, const std::string &postdata, const std::string &mimetype, const std::multimap<std::string, std::string> &headers, const std::string &protocol, time_t request_timeout) {\n\treturn async<http_request_completion_t>{ [&, this] <typename C> (C &&cc) { return this->request(url, method, std::forward<C>(cc), postdata, mimetype, headers, protocol, request_timeout); }};\n}
$cppcontent .= "dpp::async<dpp::http_request_completion_t> dpp::cluster::co_request(const std::string &url, http_method method, const std::string &postdata, const std::string &mimetype, const std::multimap<std::string, std::string> &headers, const std::string &protocol) {\n\treturn async<http_request_completion_t>{ [&, this] <typename C> (C &&cc) { return this->request(url, method, std::forward<C>(cc), postdata, mimetype, headers, protocol); }};\n}

#endif
";
Expand Down
131 changes: 0 additions & 131 deletions buildtools/classes/Generator/SyncGenerator.php

This file was deleted.

17 changes: 17 additions & 0 deletions cmake/epoll.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
macro(CHECK_EPOLL VARIABLE)
if(UNIX)
if("${VARIABLE}" MATCHES "^${VARIABLE}$")
message(STATUS "Check if the system supports epoll")
include(CheckSymbolExists)
check_symbol_exists(epoll_create "sys/epoll.h" EPOLL_PROTOTYPE_EXISTS)

if(EPOLL_PROTOTYPE_EXISTS)
message(STATUS "Check if the system supports epoll - yes")
set(${VARIABLE} 1 CACHE INTERNAL "Result of CHECK_EPOLL" FORCE)
else(EPOLL_PROTOTYPE_EXISTS)
message(STATUS "Check if the system supports epoll - no")
set(${VARIABLE} "" CACHE INTERNAL "Result of CHECK_EPOLL" FORCE)
endif(EPOLL_PROTOTYPE_EXISTS)
endif("${VARIABLE}" MATCHES "^${VARIABLE}$")
endif(UNIX)
endmacro(CHECK_EPOLL)
17 changes: 17 additions & 0 deletions cmake/kqueue.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
macro(CHECK_KQUEUE VARIABLE)
if(UNIX)
if("${VARIABLE}" MATCHES "^${VARIABLE}$")
message(STATUS "Check if the system supports kqueue")
include(CheckSymbolExists)
check_symbol_exists(kqueue "sys/event.h" KQUEUE_PROTOTYPE_EXISTS)

if(KQUEUE_PROTOTYPE_EXISTS)
message(STATUS "Check if the system supports kqueue - yes")
set(${VARIABLE} 1 CACHE INTERNAL "Result of CHECK_KQUEUE" FORCE)
else(KQUEUE_PROTOTYPE_EXISTS)
message(STATUS "Check if the system supports kqueue - no")
set(${VARIABLE} "" CACHE INTERNAL "Result of CHECK_KQUEUE" FORCE)
endif(KQUEUE_PROTOTYPE_EXISTS)
endif("${VARIABLE}" MATCHES "^${VARIABLE}$")
endif(UNIX)
endmacro(CHECK_KQUEUE)
82 changes: 30 additions & 52 deletions docpages/advanced_reference/thread_model.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
digraph "Thread Model" {
graph [ranksep=1];
node [colorscheme="blues9",fontname="helvetica"];
"Discord Events" -> "Your Program"

"Your Program" [style=filled, color=1, shape=rect]
"Cluster" [style=filled, color=1, shape=rect]

Expand All @@ -14,68 +12,48 @@ digraph "Thread Model" {
color=lightgrey;
node [style=filled,color=2]
"Your Program"
"Cluster"
label = "User Code";
"Your Program" -> "Cluster"
label = "(1)";
}

subgraph cluster_0 {
subgraph cluster_3 {
style=filled;
color=lightgrey;
node [style=filled,color=4]
"Shard 1" [style=filled, color=4]
"Shard 2"
"Shard 3..."
label = "Shards (Each is a thread, one per 2500 Discord guilds)";
node [style=filled,color=2]
"Cluster" -> "Event Loop"
"Event Loop" -> "HTTP(S) requests"
"Event Loop" -> "Voice Sessions"
"Event Loop" -> "Shards"
"Shards" -> "Websocket Events"
label = "(2)";
}

subgraph cluster_1 {
style=filled
color=lightgrey;
node [style=filled,color=4]
"REST Requests"
"Request In Queue 1"
"Request In Queue 2"
"Request In Queue 3..."
"Request Out Queue"
label = "REST Requests (Each in queue, and the out queue, are threads)"
}

subgraph cluster_3 {
style=filled
subgraph cluster_0 {
style=filled;
color=lightgrey;
node [style=filled,color=4]
"Discord Events" [style=filled,color=4]
"User Callback Functions"
label = "Events and Callbacks"
"Voice Sessions" -> "Websocket Events"
"HTTP(S) requests" -> "Thread Pool (4..n threads)"
"Websocket Events" -> "Thread Pool (4..n threads)"
"Thread Pool (4..n threads)"
label = "(3)";
}

"Cluster" [shape=rect]
"REST Requests" [shape=rect]
"Request In Queue 1" [shape=rect]
"Request In Queue 2" [shape=rect]
"Request In Queue 3..." [shape=rect]
"Shard 1" [shape=rect]
"Shard 2" [shape=rect]
"Shard 3..." [shape=rect]
"Request Out Queue" [shape=rect]
"Discord Events" [shape=rect]
"User Callback Functions" [shape=rect]
"Thread Pool (4..n threads)" [shape=rect]
"HTTP(S) requests" [shape=rect]
"Shards" [shape=rect]
"Websocket Events" [shape=rect]
"Event Loop" [shape=rect]
"Voice Sessions" [shape=rect]

"Cluster" -> "REST Requests"
"Shard 1" -> "Discord Events"
"Shard 2" -> "Discord Events"
"Shard 3..." -> "Discord Events"
"Your Program" -> "Cluster"
"Cluster" -> "Shard 1"
"Cluster" -> "Shard 2"
"Cluster" -> "Shard 3..."
"REST Requests" -> "Request In Queue 1"
"REST Requests" -> "Request In Queue 2"
"REST Requests" -> "Request In Queue 3..."
"Request In Queue 1" -> "Request Out Queue"
"Request In Queue 2" -> "Request Out Queue"
"Request In Queue 3..." -> "Request Out Queue"
"Request Out Queue" -> "User Callback Functions"
"User Callback Functions" -> "Your Program"
}
\enddot

## Details

1. User Code - No assumptions are made about how your program threads, if at all.
2. The event loop manages all socket IO for the cluster. If you start the cluster with dpp::st_return this will run under its own thread, otherwise if you use dpp::st_wait it will run in the same thread as the caller of the dpp::cluster::start method.
The event loop will be either poll, epoll or kqueue based depending on your system capabilities. You should always start a cluster after forking, if your program forks, as various types of IO loop cannot be inherited by a forked process.
3. Set thread pool size via cluster constructor. Thread pool uses a priority queue and defaults in size to half the system concurrency value. Every callback or completed coroutine ends up executing here. The minimum concurrency of this pool is 4.
2 changes: 1 addition & 1 deletion docpages/example_code/coro_awaiting_events.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ int main() {
);
co_await event.co_reply(m);

dpp::button_click_t click_event = co_await event.from->creator->on_button_click.when(
dpp::button_click_t click_event = co_await event.owner->on_button_click.when(
// Note!! Due to a bug in g++11 and g++12, id must be captured as a reference here or the compiler will destroy it twice. This is fixed in g++13
[&id] (dpp::button_click_t const &b) {
return b.custom_id == id;
Expand Down
4 changes: 2 additions & 2 deletions docpages/example_code/coro_expiring_buttons.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ int main() {
co_await event.co_reply(m);

auto result = co_await dpp::when_any{ // Whichever completes first...
event.from->creator->on_button_click.when([&id](const dpp::button_click_t &b) { // Button clicked
event.owner->on_button_click.when([&id](const dpp::button_click_t &b) { // Button clicked
return b.custom_id == id;
}),
event.from->creator->co_sleep(5) // Or sleep 5 seconds
event.owner->co_sleep(5) // Or sleep 5 seconds
};
// Note!! Due to a bug in g++11 and g++12, id must be captured as a reference above or the compiler will destroy it twice. This is fixed in g++13
if (result.index() == 0) { // Awaitable #0 completed first, that is the button click event
Expand Down
2 changes: 1 addition & 1 deletion docpages/example_code/coro_intro.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ int main() {
bot.on_slashcommand([](const dpp::slashcommand_t& event) -> dpp::task<void> {
if (event.command.get_command_name() == "file") {
/* Request the image from the URL specified and co_await the response */
dpp::http_request_completion_t result = co_await event.from->creator->co_request("https://dpp.dev/DPP-Logo.png", dpp::m_get);
dpp::http_request_completion_t result = co_await event.owner->co_request("https://dpp.dev/DPP-Logo.png", dpp::m_get);

/* Create a message and attach the image on success */
dpp::message msg(event.command.channel_id, "This is my new attachment:");
Expand Down
2 changes: 1 addition & 1 deletion docpages/example_code/coro_simple_commands1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ int main() {

bot.on_slashcommand([](const dpp::slashcommand_t& event) -> dpp::task<void> {
if (event.command.get_command_name() == "addemoji") {
dpp::cluster *cluster = event.from->creator;
dpp::cluster *cluster = event.owner;
// Retrieve parameter values
dpp::snowflake file_id = std::get<dpp::snowflake>(event.get_parameter("file"));
std::string emoji_name = std::get<std::string>(event.get_parameter("name"));
Expand Down
4 changes: 2 additions & 2 deletions docpages/example_code/coro_simple_commands2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ int main() {
}
}
// Finally if everything else failed, request API
dpp::confirmation_callback_t confirmation = co_await event.from->creator->co_guild_get_member(event.command.guild_id, user_id);
dpp::confirmation_callback_t confirmation = co_await event.owner->co_guild_get_member(event.command.guild_id, user_id);
if (confirmation.is_error()) {
co_return std::nullopt; // Member not found, return empty
} else {
Expand All @@ -53,7 +53,7 @@ int main() {

std::string avatar_url = member->get_avatar_url(512);
if (avatar_url.empty()) { // Member does not have a custom avatar for this server, get their user avatar
dpp::confirmation_callback_t confirmation = co_await event.from->creator->co_user_get_cached(member->user_id);
dpp::confirmation_callback_t confirmation = co_await event.owner->co_user_get_cached(member->user_id);
if (confirmation.is_error()) {
// Wait for the thinking response to arrive to make sure we can edit
co_await thinking;
Expand Down
4 changes: 2 additions & 2 deletions docpages/example_code/join_voice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ int main() {
dpp::guild* g = dpp::find_guild(event.command.guild_id);

/* Get the voice channel that the bot is currently in from this server (will return nullptr if we're not in a voice channel!) */
auto current_vc = event.from->get_voice(event.command.guild_id);
auto current_vc = event.from()->get_voice(event.command.guild_id);

bool join_vc = true;

Expand All @@ -38,7 +38,7 @@ int main() {
/* We are on a different voice channel. We should leave it, then join the new one
* by falling through to the join_vc branch below.
*/
event.from->disconnect_voice(event.command.guild_id);
event.from()->disconnect_voice(event.command.guild_id);

join_vc = true;
}
Expand Down
2 changes: 1 addition & 1 deletion docpages/example_code/mp3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ int main() {
event.reply("Joined your channel!");
} else if (event.command.get_command_name() == "mp3") {
/* Get the voice channel the bot is in, in this current guild. */
dpp::voiceconn* v = event.from->get_voice(event.command.guild_id);
dpp::voiceconn* v = event.from()->get_voice(event.command.guild_id);

/* If the voice channel was invalid, or there is an issue with it, then tell the user. */
if (!v || !v->voiceclient || !v->voiceclient->is_ready()) {
Expand Down
Loading
Loading