스킵 구현

This commit is contained in:
2023-12-20 19:45:25 +09:00
parent 6503fd167b
commit 8a987320e0
775 changed files with 162601 additions and 135 deletions

View File

@@ -1,7 +1,9 @@
// #include <Python.h>
#include <Commands/Play.hpp>
#include <dpp/dpp.h>
#include <dpp/nlohmann/json.hpp>
#include <stdlib.h>
#include <string>
#include <ctime>
using json = nlohmann::json;
@@ -36,6 +38,10 @@ void Play::operator()(std::list<FQueueElement>& MusicQueue, const dpp::slashcomm
}
std::string Query = std::get<std::string>(Event.get_parameter("query"));
// Event.thinking(false, [](const dpp::confirmation_callback_t &Callback) {
// return dpp::confirmation();
// });
system(("./yt-dlp -o temp --write-info-json -f 251 " + Query).c_str());
@@ -44,7 +50,7 @@ void Play::operator()(std::list<FQueueElement>& MusicQueue, const dpp::slashcomm
infofile >> document;
system("rm -f temp.info.json");
system(("ffmpeg -i temp -c copy " + std::string(to_string(document["id"])) + ".ogg").c_str());
system(("ffmpeg -y -i temp -c copy " + std::string(to_string(document["id"])) + ".ogg").c_str());
system("rm -f temp");
FQueueElement Data = {std::string(document["title"]),
@@ -55,9 +61,18 @@ void Play::operator()(std::list<FQueueElement>& MusicQueue, const dpp::slashcomm
Event.command.guild_id};
Bot->enqueue(Data);
std::cout << "queued\n";
dpp::message msg(Event.command.channel_id, "큐에 다음 곡을 추가했습니다:");
time_t SongLength = int(document["duration"]);
char SongLengthStr[10];
tm t;
t.tm_sec = SongLength%60;
t.tm_min = SongLength/60;
t.tm_hour = SongLength/360;
strftime(SongLengthStr, sizeof(SongLengthStr), "%X", &t);
msg.add_embed(dpp::embed()
.set_color(dpp::colors::sti_blue)
.set_title(document["title"])
@@ -66,12 +81,14 @@ void Play::operator()(std::list<FQueueElement>& MusicQueue, const dpp::slashcomm
.set_image(document["thumbnail"])
.add_field(
"길이",
to_string(document["duration"]),
SongLengthStr,
true
));
Event.reply(msg);
std::cout << "replied\n";
dpp::voiceconn* v = Event.from->get_voice(Event.command.guild_id);
Bot->VoiceJoinedShardId = Event.from->shard_id;

View File

@@ -13,19 +13,18 @@ Queue::Queue(std::shared_ptr<BumbleCeepp> Bot) {
void Queue::operator()(std::list<FQueueElement>& MusicQueue, const dpp::slashcommand_t& Event) {
dpp::embed embed = dpp::embed()
.set_title("큐 항목:")
.set_color(dpp::colors::sti_blue)
.set_title("영상 제목&링크")
.set_url("https://dpp.dev/")
.set_description("영상 설명란")
.set_image("https://dpp.dev/DPP-Logo.png")
.set_footer(
dpp::embed_footer()
.set_text("업로더 이름")
.set_icon("https://dpp.dev/DPP-Logo.png")
)
.set_timestamp(time(0));
dpp::message msg(Event.command.channel_id, "some Text");
for (auto iter = MusicQueue.begin(); iter != MusicQueue.end(); iter++) {
embed.add_field(
iter->title,
iter->description
);
}
dpp::message msg(Event.command.channel_id, "현재 큐에 있는 항목:");
msg.add_embed(embed);
Event.reply(msg);

30
src/Commands/Repeat.cpp Normal file
View File

@@ -0,0 +1,30 @@
#include <Commands/Repeat.hpp>
#include <dpp/dpp.h>
#include <dpp/nlohmann/json.hpp>
#include <string>
#include <ctime>
using json = nlohmann::json;
Repeat::Repeat(std::shared_ptr<BumbleCeepp> Bot) {
this->Bot = Bot;
dpp::slashcommand Command = dpp::slashcommand("repeat", "반복 켜기/끄기", Bot->BotCluster->me.id);
dpp::slashcommand Alias = dpp::slashcommand("r", "반복 켜기/끄기", Bot->BotCluster->me.id);
CommandObjectVector.push_back(Command);
CommandObjectVector.push_back(Alias);
}
void Repeat::operator()(std::list<FQueueElement>& MusicQueue, const dpp::slashcommand_t& Event) {
if (Bot->Repeat) {
Event.reply("반복을 껐습니다.");
Bot->Repeat = false;
}
else {
Event.reply("반복을 켰습니다.");
Bot->Repeat = true;
}
return;
}

31
src/Commands/Skip.cpp Normal file
View File

@@ -0,0 +1,31 @@
#include <Commands/Skip.hpp>
#include <dpp/dpp.h>
#include <dpp/nlohmann/json.hpp>
#include <string>
#include <ctime>
using json = nlohmann::json;
Skip::Skip(std::shared_ptr<BumbleCeepp> Bot) {
this->Bot = Bot;
dpp::slashcommand Command = dpp::slashcommand("skip", "현재곡 스킵", Bot->BotCluster->me.id);
dpp::slashcommand Alias = dpp::slashcommand("s", "현재곡 스킵", Bot->BotCluster->me.id);
CommandObjectVector.push_back(Command);
CommandObjectVector.push_back(Alias);
}
void Skip::operator()(std::list<FQueueElement>& MusicQueue, const dpp::slashcommand_t& Event) {
dpp::voiceconn* v = Event.from->get_voice(Event.command.guild_id);
if (!v || !v->voiceclient || !v->voiceclient->is_ready()) {
return;
}
v->voiceclient->stop_audio();
Event.reply("스킵했습니다!");
return;
}