mirror of
https://github.com/HappyTanuki/BumbleCee.git
synced 2025-10-25 17:35:58 +00:00
완성?
This commit is contained in:
@@ -13,6 +13,7 @@ public:
|
||||
return &Instance;
|
||||
}
|
||||
void enqueue(struct FQueueElement Element);
|
||||
struct FQueueElement QueueDelete(int Index);
|
||||
|
||||
void QueuePlay();
|
||||
|
||||
|
||||
@@ -6,5 +6,6 @@
|
||||
#include <Commands/Queue.hpp>
|
||||
#include <Commands/Skip.hpp>
|
||||
#include <Commands/Leave.hpp>
|
||||
#include <Commands/Delete.hpp>
|
||||
|
||||
#endif
|
||||
19
include/Commands/Delete.hpp
Normal file
19
include/Commands/Delete.hpp
Normal file
@@ -0,0 +1,19 @@
|
||||
#ifndef _DELETE_HPP_
|
||||
#define _DELETE_HPP_
|
||||
#include <CommandType.hpp>
|
||||
#include <BumbleCeepp.hpp>
|
||||
#include <memory>
|
||||
|
||||
namespace Commands {
|
||||
class Delete : public ICommand {
|
||||
public:
|
||||
Delete(std::shared_ptr<BumbleCeepp> Bot);
|
||||
|
||||
void operator()(const dpp::slashcommand_t& Event) {}
|
||||
void operator()(std::list<FQueueElement>& MusicQueue, const dpp::slashcommand_t& Event);
|
||||
private:
|
||||
std::shared_ptr<BumbleCeepp> Bot;
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -20,7 +20,7 @@ void IBot::OnReady(const dpp::ready_t& Event) {
|
||||
if (!dpp::run_once<struct register_bot_commands>())
|
||||
return;
|
||||
|
||||
//bot->global_bulk_command_delete();
|
||||
//BotCluster->global_bulk_command_delete();
|
||||
|
||||
for (auto command : CommandsArray) {
|
||||
for (auto Alias : command->CommandObjectVector) {
|
||||
|
||||
@@ -16,6 +16,17 @@ void BumbleCeepp::enqueue(struct FQueueElement Element) {
|
||||
QueueMutex.unlock();
|
||||
}
|
||||
|
||||
struct FQueueElement BumbleCeepp::QueueDelete(int Index) {
|
||||
QueueMutex.lock();
|
||||
auto iter = MusicQueue.begin();
|
||||
std::advance(iter, Index);
|
||||
auto ReturnValue = *iter;
|
||||
MusicQueue.erase(iter);
|
||||
QueueMutex.unlock();
|
||||
|
||||
return ReturnValue;
|
||||
}
|
||||
|
||||
void BumbleCeepp::QueuePlay(){
|
||||
if (QueuePlaying) {
|
||||
return;
|
||||
@@ -33,11 +44,6 @@ void BumbleCeepp::QueuePlay(){
|
||||
FQueueElement Music = MusicQueue.front();
|
||||
QueueMutex.unlock();
|
||||
|
||||
std::cout << "Queue:\n";
|
||||
for (auto iter = MusicQueue.begin(); iter != MusicQueue.end(); iter++) {
|
||||
std::cout << iter->title << "\n";
|
||||
}
|
||||
|
||||
dpp::voiceconn* v = JoinedShared->get_voice(Music.guild_id);
|
||||
if (!v || !v->voiceclient || !v->voiceclient->is_ready()) {
|
||||
return;
|
||||
@@ -95,6 +101,10 @@ void BumbleCeepp::QueuePlay(){
|
||||
while(v->voiceclient->is_playing()) {}
|
||||
|
||||
QueueMutex.lock();
|
||||
if (MusicQueue.empty()) {
|
||||
QueueMutex.unlock();
|
||||
break;
|
||||
}
|
||||
MusicQueue.pop_front();
|
||||
QueueMutex.unlock();
|
||||
|
||||
|
||||
39
src/Commands/Delete.cpp
Normal file
39
src/Commands/Delete.cpp
Normal 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);
|
||||
}
|
||||
}
|
||||
@@ -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) {
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -16,12 +16,14 @@ int main() {
|
||||
Commands::Queue Command3(BumbleBee);
|
||||
Commands::Skip Command4(BumbleBee);
|
||||
Commands::Leave Command5(BumbleBee);
|
||||
Commands::Delete Command6(BumbleBee);
|
||||
|
||||
BumbleBee->AddCommand(Command1);
|
||||
BumbleBee->AddCommand(Command2);
|
||||
BumbleBee->AddCommand(Command3);
|
||||
BumbleBee->AddCommand(Command4);
|
||||
BumbleBee->AddCommand(Command5);
|
||||
BumbleBee->AddCommand(Command6);
|
||||
|
||||
BumbleBee->Start();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user