mirror of
https://github.com/HappyTanuki/BumbleCee.git
synced 2025-10-26 01:45:15 +00:00
와 이제 진짜 진짜 버그 다 고친 듯?
This commit is contained in:
@@ -1,6 +1,4 @@
|
||||
#pragma once
|
||||
#ifndef _MUSICPLAYMANAGER_HPP_
|
||||
#define _MUSICPLAYMANAGER_HPP_
|
||||
#include <dpp/dpp.h>
|
||||
#include <Queue/MusicQueue.hpp>
|
||||
#include <condition_variable>
|
||||
@@ -50,7 +48,7 @@ public:
|
||||
void setRepeat(const dpp::snowflake guildId, const bool value);
|
||||
bool getRepeat(const dpp::snowflake guildId);
|
||||
|
||||
std::list<MusicQueueElement> getQueue(const dpp::snowflake guildId);
|
||||
std::pair<std::shared_ptr<std::list<std::shared_ptr<MusicQueueElement>>>, std::list<std::shared_ptr<MusicQueueElement>>::iterator> getQueue(const dpp::snowflake guildId);
|
||||
MusicQueueElement getNowPlaying(const dpp::snowflake guildId);
|
||||
|
||||
std::condition_variable queuedCondition;
|
||||
@@ -63,7 +61,6 @@ private:
|
||||
|
||||
std::unordered_map<dpp::snowflake, std::shared_ptr<std::mutex>> queueEmptyMutex;
|
||||
|
||||
void send_audio_to_voice(const MusicQueueElement& music, dpp::discord_voice_client* client);
|
||||
void send_audio_to_voice(std::shared_ptr<bumbleBee::MusicQueueElement> music, dpp::discord_voice_client* client);
|
||||
};
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -1,6 +1,4 @@
|
||||
#pragma once
|
||||
#ifndef _BUMBLEBEECOMMAND_HPP_
|
||||
#define _BUMBLEBEECOMMAND_HPP_
|
||||
#include <dpp/dpp.h>
|
||||
#include <Audio/MusicPlayManager.hpp>
|
||||
#include <functional>
|
||||
@@ -65,6 +63,4 @@ _DECLARE_BUMBLEBEE_COMMAND(Play, p, "노래 재생")
|
||||
_DECLARE_BUMBLEBEE_COMMAND(Queue, q, "노래 예약 큐를 확인합니다")
|
||||
_DECLARE_BUMBLEBEE_COMMAND(Repeat, r, "반복을 켜거나 끕니다")
|
||||
_DECLARE_BUMBLEBEE_COMMAND(Skip, s, "현재 재생중인 곡을 스킵합니다")
|
||||
_DECLARE_BUMBLEBEE_COMMAND(Shuffle, shuffle, "큐를 섞습니다")
|
||||
|
||||
#endif
|
||||
_DECLARE_BUMBLEBEE_COMMAND(Shuffle, shuffle, "큐를 섞습니다")
|
||||
@@ -1,6 +1,4 @@
|
||||
#pragma once
|
||||
#ifndef _MUSICQUEUE_HPP_
|
||||
#define _MUSICQUEUE_HPP_
|
||||
#include <memory>
|
||||
#include <functional>
|
||||
#include <condition_variable>
|
||||
@@ -17,17 +15,18 @@ public:
|
||||
currentPlayingPosition = queue.begin();
|
||||
repeat = true;
|
||||
}
|
||||
void enqueue(std::shared_ptr<MusicQueueElement> Element);
|
||||
std::shared_ptr<MusicQueueElement> dequeue();
|
||||
std::list<std::shared_ptr<MusicQueueElement>>::iterator findById(std::string id);
|
||||
std::list<std::shared_ptr<MusicQueueElement>>::iterator findByIndex(int index);
|
||||
std::shared_ptr<MusicQueueElement> nowplaying();
|
||||
std::list<std::shared_ptr<MusicQueueElement>>::iterator next_music();
|
||||
std::shared_ptr<MusicQueueElement> jump_to_index(int idx);
|
||||
void clear();
|
||||
std::shared_ptr<MusicQueueElement> erase(std::list<std::shared_ptr<MusicQueueElement>>::iterator it);
|
||||
std::list<std::shared_ptr<MusicQueueElement>> getQueueCopy();
|
||||
int size();
|
||||
void enqueue(std::shared_ptr<MusicQueueElement> Element);
|
||||
std::shared_ptr<MusicQueueElement> dequeue();
|
||||
std::list<std::shared_ptr<MusicQueueElement>>::iterator findById(std::string id);
|
||||
std::list<std::shared_ptr<MusicQueueElement>>::iterator findByIndex(int index);
|
||||
std::shared_ptr<MusicQueueElement> nowplaying();
|
||||
std::list<std::shared_ptr<MusicQueueElement>>::iterator next_music();
|
||||
std::shared_ptr<MusicQueueElement> jump_to_index(int idx);
|
||||
void clear();
|
||||
std::shared_ptr<MusicQueueElement> erase(std::list<std::shared_ptr<MusicQueueElement>>::iterator it);
|
||||
std::pair<std::shared_ptr<std::list<std::shared_ptr<MusicQueueElement>>>, std::list<std::shared_ptr<MusicQueueElement>>::iterator> getQueueCopy();
|
||||
int size();
|
||||
std::list<std::shared_ptr<MusicQueueElement>>::iterator end();
|
||||
|
||||
bool repeat;
|
||||
|
||||
@@ -36,6 +35,4 @@ private:
|
||||
std::list<std::shared_ptr<MusicQueueElement>> queue;
|
||||
std::mutex queueMutex;
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
}
|
||||
@@ -1,6 +1,4 @@
|
||||
#pragma once
|
||||
#ifndef _MUSICQUEUEELEMENT_HPP_
|
||||
#define _MUSICQUEUEELEMENT_HPP_
|
||||
#include <dpp/dpp.h>
|
||||
|
||||
namespace bumbleBee {
|
||||
@@ -19,5 +17,4 @@ public:
|
||||
const dpp::user issuingUser;
|
||||
const dpp::embed embed;
|
||||
};
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -1,6 +1,4 @@
|
||||
#pragma once
|
||||
#ifndef _SETTINGSMANAGER_HPP_
|
||||
#define _SETTINGSMANAGER_HPP_
|
||||
#include <dpp/dpp.h>
|
||||
|
||||
#define _DECLARE_DEFAULT_ACCESSER_STATIC_VARIABLE(type, name, Name)\
|
||||
@@ -33,5 +31,4 @@ public:
|
||||
/// @return 유효한 토큰이면 true, 아니면 false를 반환합니다.
|
||||
static bool validateToken();
|
||||
};
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -1,6 +1,4 @@
|
||||
#pragma once
|
||||
#ifndef _ASYNCDOWNLOADMANAGER_HPP_
|
||||
#define _ASYNCDOWNLOADMANAGER_HPP_
|
||||
#include <queue>
|
||||
#include <string>
|
||||
#include <thread>
|
||||
@@ -55,6 +53,4 @@ private:
|
||||
std::vector<std::thread> worker_thread;
|
||||
bool terminate;
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
}
|
||||
@@ -1,6 +1,4 @@
|
||||
#pragma once
|
||||
#ifndef _CONSOLEUTILS_HPP_
|
||||
#define _CONSOLEUTILS_HPP_
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
#include <queue>
|
||||
@@ -35,6 +33,4 @@ public:
|
||||
return tokens;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
}
|
||||
84
include/Utils/QueuedMusicListEmbedProvider.hpp
Normal file
84
include/Utils/QueuedMusicListEmbedProvider.hpp
Normal file
@@ -0,0 +1,84 @@
|
||||
#pragma once
|
||||
#include <dpp/dpp.h>
|
||||
#include <Queue/MusicQueueElement.hpp>
|
||||
#include <cmath>
|
||||
|
||||
namespace bumbleBee {
|
||||
class QueuedMusicListEmbedProvider {
|
||||
public:
|
||||
static std::queue<dpp::embed> makeEmbed(std::list<std::shared_ptr<MusicQueueElement>> queue, std::list<std::shared_ptr<MusicQueueElement>>::iterator np, bool repeat) {
|
||||
std::queue<dpp::embed> returnValue;
|
||||
std::list<std::shared_ptr<MusicQueueElement>>::iterator it = queue.begin();
|
||||
if (queue.size() == 0) {
|
||||
dpp::embed embed = makeEmbedPart(queue, np, repeat, it);
|
||||
returnValue.push(embed);
|
||||
return returnValue;
|
||||
}
|
||||
for (int i = 0; i < std::ceil(queue.size() / 5.0); i++) {
|
||||
dpp::embed embed = makeEmbedPart(queue, np, repeat, it);
|
||||
returnValue.push(embed);
|
||||
}
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
static int distance(const std::list<std::shared_ptr<MusicQueueElement>>::iterator a, const std::list<std::shared_ptr<MusicQueueElement>>::iterator b) {
|
||||
int i = 0;
|
||||
std::list<std::shared_ptr<MusicQueueElement>>::iterator mutatea = a;
|
||||
while (mutatea++ == b)
|
||||
i++;
|
||||
return i;
|
||||
}
|
||||
private:
|
||||
static dpp::embed makeEmbedPart(
|
||||
std::list<std::shared_ptr<MusicQueueElement>> queue,
|
||||
std::list<std::shared_ptr<MusicQueueElement>>::iterator np,
|
||||
bool repeat,
|
||||
std::list<std::shared_ptr<MusicQueueElement>>::iterator startIter) {
|
||||
dpp::embed embed = dpp::embed()
|
||||
.set_color(dpp::colors::sti_blue);
|
||||
|
||||
if (queue.begin() == queue.end()) {
|
||||
embed
|
||||
.set_title("큐가 비었습니다!")
|
||||
.set_timestamp(time(0));
|
||||
|
||||
if (repeat)
|
||||
embed.add_field(":repeat:","");
|
||||
|
||||
return embed;
|
||||
}
|
||||
|
||||
int startIndex = distance(queue.begin(), startIter) + 1;
|
||||
int index = startIndex;
|
||||
|
||||
for (; (index < startIndex + 5) && startIter != queue.end() && index < queue.size()+1; startIter++, index++) { //iter로 순회하면 왠지 모르게 이상한 값을 읽을 때가 있음 이유는 나도 몰?루
|
||||
if (*startIter == *np)
|
||||
embed.add_field (
|
||||
"np",
|
||||
"",
|
||||
true
|
||||
);
|
||||
else
|
||||
embed.add_field (
|
||||
std::to_string(index),
|
||||
"",
|
||||
true
|
||||
);
|
||||
embed.add_field (
|
||||
(*startIter)->embed.title,
|
||||
(*startIter)->embed.description,
|
||||
true
|
||||
)
|
||||
.add_field("","");
|
||||
}
|
||||
|
||||
if (startIter == queue.end() || index >= queue.size()+1) {
|
||||
embed.set_timestamp(time(0));
|
||||
if (repeat)
|
||||
embed.add_field(":repeat:","");
|
||||
}
|
||||
|
||||
return embed;
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -1,6 +1,4 @@
|
||||
#pragma once
|
||||
#ifndef _VERSIONCHECKUTILS_HPP_
|
||||
#define _VERSIONCHECKUTILS_HPP_
|
||||
#include <dpp/dpp.h>
|
||||
#include "ConsoleUtils.hpp"
|
||||
#include "../Settings/SettingsManager.hpp"
|
||||
@@ -73,5 +71,4 @@ public:
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
#endif
|
||||
}
|
||||
Reference in New Issue
Block a user