11
11
// #include "CommonFramework/Globals.h"
12
12
// #include "CommonFramework/GlobalSettingsPanel.h"
13
13
#include " DppIntegration/DppClient.h"
14
- #include " SleepyDiscordRunner.h"
15
14
#include " DiscordIntegrationSettings.h"
16
15
17
16
// #include <iostream>
@@ -23,7 +22,6 @@ namespace Integration{
23
22
24
23
25
24
DiscordIntegrationSettingsOption::~DiscordIntegrationSettingsOption (){
26
- library0.remove_listener (*this );
27
25
this ->remove_listener (*this );
28
26
}
29
27
DiscordIntegrationSettingsOption::DiscordIntegrationSettingsOption ()
@@ -38,15 +36,6 @@ DiscordIntegrationSettingsOption::DiscordIntegrationSettingsOption()
38
36
LockMode::LOCK_WHILE_RUNNING,
39
37
false
40
38
)
41
- , library0(
42
- " <b>Discord Integration Library:</b><br>Restart the program for this to take effect." ,
43
- {
44
- {Library::SleepyDiscord, " sleepy" , " Sleepy Discord (normal commands, deprecated)" },
45
- {Library::DPP, " dpp" , " D++ (slash commands and normal commands)" },
46
- },
47
- LockMode::LOCK_WHILE_RUNNING,
48
- Library::DPP
49
- )
50
39
, command_type(
51
40
" <b>Discord Integration Command Type:</b><br>Restart the program for this to take effect." ,
52
41
{
@@ -68,11 +57,6 @@ DiscordIntegrationSettingsOption::DiscordIntegrationSettingsOption()
68
57
LockMode::LOCK_WHILE_RUNNING,
69
58
" ^" , " ^"
70
59
)
71
- , use_suffix(
72
- " <b>Use Suffix (Sleepy):</b><br>Use a suffix instead of a prefix for commands." ,
73
- LockMode::LOCK_WHILE_RUNNING,
74
- false
75
- )
76
60
, game_status(
77
61
false ,
78
62
" <b>Discord Game Status:</b><br>Enter a status message your bot would display." ,
@@ -85,87 +69,39 @@ DiscordIntegrationSettingsOption::DiscordIntegrationSettingsOption()
85
69
LockMode::LOCK_WHILE_RUNNING,
86
70
" " , " Automation at your service!"
87
71
)
88
- , sudo(
89
- false ,
90
- " <b>Discord Sudo (Sleepy):</b><br>Enter user ID(s) to grant sudo access to." ,
91
- LockMode::LOCK_WHILE_RUNNING,
92
- " " , " 123456789012345678"
93
- )
94
- , owner(
95
- false ,
96
- " <b>Discord Owner (Sleepy):</b><br>Enter the bot owner's ID (your own ID)." ,
97
- LockMode::LOCK_WHILE_RUNNING,
98
- " " , " 123456789012345678"
99
- )
100
72
, allow_buttons_from_users(
101
73
" <b>Allow Buttons from Users:</b><br>Allow other users to issue button presses." ,
102
74
LockMode::LOCK_WHILE_RUNNING,
103
75
false
104
76
)
105
77
{
106
78
PA_ADD_OPTION (run_on_start);
107
- PA_ADD_OPTION (library0);
108
79
PA_ADD_OPTION (command_type);
109
80
PA_ADD_OPTION (token);
110
81
PA_ADD_OPTION (command_prefix);
111
- PA_ADD_OPTION (use_suffix);
112
82
PA_ADD_OPTION (game_status);
113
83
PA_ADD_OPTION (hello_message);
114
- PA_ADD_OPTION (sudo);
115
- PA_ADD_OPTION (owner);
116
84
PA_ADD_OPTION (allow_buttons_from_users);
117
85
PA_ADD_OPTION (channels);
118
86
119
87
DiscordIntegrationSettingsOption::on_config_value_changed (this );
120
88
121
89
this ->add_listener (*this );
122
- library0.add_listener (*this );
123
90
}
124
91
void DiscordIntegrationSettingsOption::on_config_value_changed ([[maybe_unused]] void * object){
125
92
// cout << this->enabled() << endl;
126
- #if (defined PA_SLEEPY || defined PA_DPP)
127
- bool options_enabled = this ->enabled ();
128
- switch (library0){
129
- #ifdef PA_SLEEPY
130
- case Library::SleepyDiscord:{
131
- options_enabled &= !SleepyDiscordRunner::is_running ();
132
- ConfigOptionState state = options_enabled ? ConfigOptionState::ENABLED : ConfigOptionState::DISABLED;
133
-
134
- library0.set_visibility (state);
135
- command_type.set_visibility (ConfigOptionState::HIDDEN);
136
- token.set_visibility (state);
137
- game_status.set_visibility (state);
138
- hello_message.set_visibility (state);
139
-
140
- command_prefix.set_visibility (state);
141
- use_suffix.set_visibility (state);
142
- sudo.set_visibility (state);
143
- owner.set_visibility (state);
144
- allow_buttons_from_users.set_visibility (ConfigOptionState::HIDDEN);
145
- break ;
146
- }
147
- #endif
148
93
#ifdef PA_DPP
149
- case Library::DPP:{
150
- options_enabled &= !DppClient::Client::instance ().is_initialized ();
151
- ConfigOptionState state = options_enabled ? ConfigOptionState::ENABLED : ConfigOptionState::DISABLED;
152
-
153
- library0.set_visibility (state);
154
- command_type.set_visibility (state);
155
- token.set_visibility (state);
156
- game_status.set_visibility (state);
157
- hello_message.set_visibility (state);
158
- allow_buttons_from_users.set_visibility (state);
159
-
160
- command_prefix.set_visibility (state);
161
- use_suffix.set_visibility (ConfigOptionState::HIDDEN);
162
- sudo.set_visibility (ConfigOptionState::HIDDEN);
163
- owner.set_visibility (ConfigOptionState::HIDDEN);
164
- break ;
165
- }
166
- #endif
167
- default :;
168
- }
94
+ bool options_enabled = this ->enabled ();
95
+ options_enabled &= !DppClient::Client::instance ().is_initialized ();
96
+ ConfigOptionState state = options_enabled ? ConfigOptionState::ENABLED : ConfigOptionState::DISABLED;
97
+
98
+ command_type.set_visibility (state);
99
+ token.set_visibility (state);
100
+ game_status.set_visibility (state);
101
+ hello_message.set_visibility (state);
102
+ allow_buttons_from_users.set_visibility (state);
103
+
104
+ command_prefix.set_visibility (state);
169
105
#endif
170
106
}
171
107
@@ -181,7 +117,7 @@ ConfigWidget* DiscordIntegrationSettingsOption::make_QtWidget(QWidget& parent){
181
117
DiscordIntegrationSettingsWidget::DiscordIntegrationSettingsWidget (QWidget& parent, DiscordIntegrationSettingsOption& value)
182
118
: GroupWidget(parent, value)
183
119
{
184
- #if (defined PA_SLEEPY || defined PA_DPP)
120
+ #ifdef PA_DPP
185
121
186
122
QWidget* control_buttons = new QWidget (this );
187
123
m_options_layout->insertWidget (0 , control_buttons);
@@ -207,38 +143,14 @@ DiscordIntegrationSettingsWidget::DiscordIntegrationSettingsWidget(QWidget& pare
207
143
connect (
208
144
button_start, &QPushButton::clicked,
209
145
this , [this , &value](bool ){
210
- switch (value.library0 ){
211
- #ifdef PA_SLEEPY
212
- case DiscordIntegrationSettingsOption::Library::SleepyDiscord:
213
- SleepyDiscordRunner::sleepy_connect ();
214
- break ;
215
- #endif
216
- #ifdef PA_DPP
217
- case DiscordIntegrationSettingsOption::Library::DPP:
218
- DppClient::Client::instance ().connect ();
219
- break ;
220
- #endif
221
- default :;
222
- }
146
+ DppClient::Client::instance ().connect ();
223
147
value.on_config_value_changed (this );
224
148
}
225
149
);
226
150
connect (
227
151
button_stop, &QPushButton::clicked,
228
152
this , [this , &value](bool ){
229
- switch (value.library0 ){
230
- #ifdef PA_SLEEPY
231
- case DiscordIntegrationSettingsOption::Library::SleepyDiscord:
232
- SleepyDiscordRunner::sleepy_terminate ();
233
- break ;
234
- #endif
235
- #ifdef PA_DPP
236
- case DiscordIntegrationSettingsOption::Library::DPP:
237
- DppClient::Client::instance ().disconnect ();
238
- break ;
239
- #endif
240
- default :;
241
- }
153
+ DppClient::Client::instance ().disconnect ();
242
154
value.on_config_value_changed (this );
243
155
}
244
156
);
0 commit comments