This commit is contained in:
2023-12-28 01:32:04 +09:00
parent 52c4bdf3d4
commit 5f08bc4c09
12 changed files with 129 additions and 28 deletions

39
src/Commands/Delete.cpp Normal file
View File

@@ -0,0 +1,39 @@
#include <Commands/Delete.hpp>
#include <iostream>
namespace Commands {
Delete::Delete(std::shared_ptr<BumbleCeepp> Bot) {
this->Bot = Bot;
dpp::slashcommand Command = dpp::slashcommand("d", "큐의 해당하는 번호의 노래를 지웁니다", Bot->BotCluster->me.id);
Command.add_option(
dpp::command_option(dpp::co_string, "pos", "큐 번호", Bot->BotCluster->me.id)
);
CommandObjectVector.push_back(Command);
}
void Delete::operator()(std::list<FQueueElement>& MusicQueue, const dpp::slashcommand_t& Event) {
std::string Pos = std::get<std::string>(Event.get_parameter("pos"));
if (!atoi(Pos.c_str())) {
dpp::message msg(Event.command.channel_id, "현재 재생중인 곡은 삭제할 수 없습니다!");
Event.reply(msg);
return;
}
auto PopedElement = Bot->QueueDelete(atoi(Pos.c_str()));
dpp::embed embed = dpp::embed()
.set_title(PopedElement.title)
.set_description(PopedElement.description)
.set_color(dpp::colors::sti_blue)
.set_image(PopedElement.thumbnail)
.set_timestamp(time(0));
dpp::message msg(Event.command.channel_id, "다음 항목을 큐에서 삭제했습니다!:");
msg.add_embed(embed);
Event.reply(msg);
}
}

View File

@@ -5,11 +5,9 @@ namespace Commands {
Leave::Leave(std::shared_ptr<BumbleCeepp> Bot) {
this->Bot = Bot;
dpp::slashcommand Command = dpp::slashcommand("leave", "음챗을 떠납니다", Bot->BotCluster->me.id);
dpp::slashcommand Alias = dpp::slashcommand("l", "음챗을 떠납니다", Bot->BotCluster->me.id);
dpp::slashcommand Command = dpp::slashcommand("l", "음챗을 떠납니다", Bot->BotCluster->me.id);
CommandObjectVector.push_back(Command);
CommandObjectVector.push_back(Alias);
}
void Leave::operator()(std::list<FQueueElement>& MusicQueue, const dpp::slashcommand_t& Event) {

View File

@@ -1,4 +1,3 @@
// #include <Python.h>
#include <Commands/Play.hpp>
#include <dpp/dpp.h>
#include <dpp/nlohmann/json.hpp>
@@ -11,20 +10,13 @@ namespace Commands {
Play::Play(std::shared_ptr<BumbleCeepp> Bot) {
this->Bot = Bot;
dpp::slashcommand Command = dpp::slashcommand("play", "노래 재생", Bot->BotCluster->me.id);
dpp::slashcommand Command = dpp::slashcommand("p", "노래 재생", Bot->BotCluster->me.id);
Command.add_option(
dpp::command_option(dpp::co_string, "query", "링크 또는 검색어", Bot->BotCluster->me.id)
);
dpp::slashcommand Alias = dpp::slashcommand("p", "노래 재생", Bot->BotCluster->me.id);
Alias.add_option(
dpp::command_option(dpp::co_string, "query", "링크 또는 검색어", Bot->BotCluster->me.id)
);
CommandObjectVector.push_back(Command);
CommandObjectVector.push_back(Alias);
}
void Play::operator()(std::list<FQueueElement>& MusicQueue, const dpp::slashcommand_t& Event) {

View File

@@ -5,26 +5,69 @@ namespace Commands {
Queue::Queue(std::shared_ptr<BumbleCeepp> Bot) {
this->Bot = Bot;
dpp::slashcommand Command = dpp::slashcommand("queue", "노래 예약 큐 확인", Bot->BotCluster->me.id);
dpp::slashcommand Alias = dpp::slashcommand("q", "노래 예약 큐 확인", Bot->BotCluster->me.id);
dpp::slashcommand Command = dpp::slashcommand("q", "노래 예약 큐 확인", Bot->BotCluster->me.id);
CommandObjectVector.push_back(Command);
CommandObjectVector.push_back(Alias);
}
void Queue::operator()(std::list<FQueueElement>& MusicQueue, const dpp::slashcommand_t& Event) {
if (MusicQueue.empty()) {
dpp::embed embed = dpp::embed()
.set_title("큐가 비었습니다!")
.set_color(dpp::colors::sti_blue)
.set_timestamp(time(0));
if (Bot->Repeat)
embed.add_field(":repeat:","");
dpp::message msg(Event.command.channel_id, "현재 큐에 있는 항목:");
msg.add_embed(embed);
Event.reply(msg);
return;
}
dpp::embed embed = dpp::embed()
.set_title("큐 항목:")
.set_color(dpp::colors::sti_blue)
.set_timestamp(time(0));
int i = 0;
char number[30] = {0, };
for (auto iter = MusicQueue.begin(); iter != MusicQueue.end(); iter++) {
if (!i) {
embed.add_field(
"현재 재생 중",
"",
true
);
}
else {
sprintf(number, "%d", i);
embed.add_field(
number,
"",
true
);
}
embed.add_field(
iter->title,
iter->description
iter->description,
true
)
.add_field(
"",
""
);
i++;
}
if (Bot->Repeat)
embed.add_field(":repeat:","");
dpp::message msg(Event.command.channel_id, "현재 큐에 있는 항목:");
msg.add_embed(embed);

View File

@@ -6,11 +6,9 @@ namespace Commands {
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);
dpp::slashcommand Command = 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) {

View File

@@ -6,11 +6,9 @@ namespace Commands {
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);
dpp::slashcommand Command = 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) {