-
Notifications
You must be signed in to change notification settings - Fork 2
/
Clear.hpp
73 lines (56 loc) · 2.17 KB
/
Clear.hpp
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
// clear.hpp - header for the "clear" command.
// aug 19, 2021
// chris m.
// https://github.com/real_time_chris
#pragma once
#include "HelperFunctions.hpp"
namespace discord_core_api {
class clear : public base_function {
public:
clear() {
this->commandName = "clear";
this->helpDescription = "Clears the current song queue.";
embed_data msgEmbed{};
msgEmbed.setDescription("------\nSimply enter /clear! and that's it!\n------");
msgEmbed.setTitle("__**Clear Usage:**__");
msgEmbed.setTimeStamp(getTimeAndDate());
msgEmbed.setColor("fefefe");
this->helpEmbed = msgEmbed;
}
unique_ptr<base_function> create() {
return makeUnique<clear>();
}
void execute(const base_function_arguments& argsNew) {
try {
channel_data channel{ argsNew.getChannelData() };
guild_data guild{ argsNew.getInteractionData().guildId };
discord_guild discordGuild{ guild };
bool checkIfAllowedInChannel = checkIfAllowedPlayingInChannel(argsNew.getInputEventData(), discordGuild);
if (!checkIfAllowedInChannel) {
return;
}
guild_member_data guildMember{ argsNew.getGuildMemberData() };
bool doWeHaveControl = checkIfWeHaveControl(argsNew.getInputEventData(), discordGuild, guildMember);
if (!doWeHaveControl) {
return;
}
discordGuild.data.playlist = playlist{};
discordGuild.writeDataToDB();
embed_data msgEmbed{};
msgEmbed.setAuthor(argsNew.getUserData().userName, argsNew.getUserData().getUserImageUrl<user_image_types::Avatar>());
msgEmbed.setColor("fefefe");
msgEmbed.setDescription("\n------\n__**You have cleared the song queue!**__\n------");
msgEmbed.setTimeStamp(getTimeAndDate());
msgEmbed.setTitle("__**Queue Cleared:**__");
respond_to_input_event_data dataPackage(argsNew.getInputEventData());
dataPackage.setResponseType(input_event_response_type::Ephemeral_Interaction_Response);
dataPackage.addMessageEmbed(msgEmbed);
auto newEvent = input_events::respondToInputEventAsync(dataPackage).get();
return;
} catch (const std::runtime_error& error) {
std::cout << "clear::execute()" << error.what() << std::endl;
}
}
~clear(){};
};
}// namespace discord_core_api