Debian Codegraph @

src/dpp/voicestate.cpp

raw symbols SCIP
1 /************************************************************************************
2 *
3 * D++, A Lightweight C++ library for Discord
4 *
5 * SPDX-License-Identifier: Apache-2.0
6 * Copyright 2021 Craig Edwards and D++ contributors
7 * (https://github.com/brainboxdotcc/DPP/graphs/contributors)
8 *
9 * Licensed under the Apache License, Version 2.0 (the "License");
10 * you may not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
12 *
13 * http://www.apache.org/licenses/LICENSE-2.0
14 *
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
20 *
21 ************************************************************************************/
22 #include <dpp/voicestate.h>
23 #include <dpp/discordevents.h>
24 #include <dpp/json.h>
25
26 namespace dpp {
27
28 using json = nlohmann::json;
29
30 voicestate::voicestate() : shard_id(0), guild_id(0), channel_id(0), user_id(0), request_to_speak(0)
31 {
32 }
33
34 voicestate& voicestate::fill_from_json_impl(nlohmann::json* j) {
35 set_snowflake_not_null(j, "guild_id", guild_id);
36 set_snowflake_not_null(j, "channel_id", channel_id);
37 set_snowflake_not_null(j, "user_id", user_id);
38 set_string_not_null(j, "session_id", session_id);
39 set_ts_not_null(j, "request_to_speak_timestamp", request_to_speak);
40
41 if (bool_not_null(j, "deaf")) {
42 flags |= vs_deaf;
43 }
44 if (bool_not_null(j, "mute")) {
45 flags |= vs_mute;
46 }
47 if (bool_not_null(j, "self_mute")) {
48 flags |= vs_self_mute;
49 }
50 if (bool_not_null(j, "self_deaf")) {
51 flags |= vs_self_deaf;
52 }
53 if (bool_not_null(j, "self_stream")) {
54 flags |= vs_self_stream;
55 }
56 if (bool_not_null(j, "self_video")) {
57 flags |= vs_self_video;
58 }
59 if (bool_not_null(j, "suppress")) {
60 flags |= vs_suppress;
61 }
62 return *this;
63 }
64
65 bool voicestate::is_deaf() const {
66 return flags & vs_deaf;
67 }
68
69 bool voicestate::is_mute() const {
70 return flags & vs_mute;
71 }
72
73 bool voicestate::is_self_mute() const {
74 return flags & vs_self_mute;
75 }
76
77 bool voicestate::is_self_deaf() const {
78 return flags & vs_self_deaf;
79 }
80
81 bool voicestate::self_stream() const {
82 return flags & vs_self_stream;
83 }
84
85 bool voicestate::self_video() const {
86 return flags & vs_self_video;
87 }
88
89 bool voicestate::is_suppressed() const {
90 return flags & vs_suppress;
91 }
92
93 }