음악 큐/재생 구현 todo:음성 잔랙 없애기

This commit is contained in:
2023-12-14 02:39:12 +09:00
parent b2f40f21cf
commit 6503fd167b
21 changed files with 356 additions and 232 deletions

View File

@@ -1,5 +1,6 @@
#pragma once
#include "CommandType.hpp"
#ifndef _BOT_HPP_
#define _BOT_HPP_
#include <CommandType.hpp>
#include <dpp/dpp.h>
#include <memory>
@@ -10,10 +11,12 @@ public:
void AddCommand(ICommand &Command);
void Start();
std::shared_ptr<dpp::cluster> bot;
std::shared_ptr<dpp::cluster> BotCluster;
protected:
virtual void OnReady(const dpp::ready_t& event);
virtual void OnCommand(const dpp::slashcommand_t& event);
std::vector<ICommand*> CommandsArray;
};
};
#endif

View File

@@ -1,7 +1,10 @@
#pragma once
#include "Bot.hpp"
#ifndef _BUMBLECEEPP_HPP_
#define _BUMBLECEEPP_HPP_
#include <string>
#include <list>
#include <mutex>
#include <Bot.hpp>
#include <dpp/dpp.h>
class BumbleCeepp : public IBot {
public:
@@ -9,12 +12,19 @@ public:
static BumbleCeepp Instance(Token);
return &Instance;
}
void enqueue(std::string);
std::string dequeue();
void enqueue(struct FQueueElement Element);
void QueuePlay();
uint32_t VoiceJoinedShardId;
protected:
std::list<std::string> MusicQueue;
private:
BumbleCeepp(std::string Token);
void OnCommand(const dpp::slashcommand_t& Event);
};
std::list<struct FQueueElement> MusicQueue;
std::mutex QueueMutex;
};
#endif

View File

@@ -1,12 +1,16 @@
#pragma once
#ifndef _COMMANDTYPE_HPP_
#define _COMMANDTYPE_HPP_
#include <dpp/dpp.h>
#include <vector>
#include <list>
#include <FQueueElement.hpp>
class ICommand {
public:
virtual void operator() (const dpp::slashcommand_t& Event) = 0;
virtual void operator() (std::list<std::string>& MusicQueue, const dpp::slashcommand_t& Event) = 0;
virtual void operator() (std::list<FQueueElement>& MusicQueue, const dpp::slashcommand_t& Event) = 0;
std::vector<dpp::slashcommand> CommandObjectVector;
};
};
#endif

View File

@@ -1,4 +1,5 @@
#pragma once
#include "Commands/Play.hpp"
#include "Commands/Queue.hpp"
#include "Commands/Join.hpp"
#ifndef _COMMANDS_HPP_
#define _COMMANDS_HPP_
#include <Commands/Play.hpp>
#endif

View File

@@ -1,10 +0,0 @@
#pragma once
#include "../CommandType.hpp"
class Join : public ICommand {
public:
Join(dpp::snowflake Id);
void operator()(const dpp::slashcommand_t& Event) {}
void operator()(std::list<std::string>& MusicQueue, const dpp::slashcommand_t& Event);
};

View File

@@ -1,10 +1,17 @@
#pragma once
#include "../CommandType.hpp"
#ifndef _PLAY_HPP_
#define _PLAY_HPP_
#include <CommandType.hpp>
#include <BumbleCeepp.hpp>
#include <memory>
class Play : public ICommand {
public:
Play(dpp::snowflake Id);
Play(std::shared_ptr<BumbleCeepp> Bot);
void operator()(const dpp::slashcommand_t& Event) {}
void operator()(std::list<std::string>& MusicQueue, const dpp::slashcommand_t& Event);
};
void operator()(std::list<FQueueElement>& MusicQueue, const dpp::slashcommand_t& Event);
private:
std::shared_ptr<BumbleCeepp> Bot;
};
#endif

View File

@@ -1,10 +1,17 @@
#pragma once
#include "../CommandType.hpp"
#ifndef _QUEUE_HPP_
#define _QUEUE_HPP_
#include <CommandType.hpp>
#include <BumbleCeepp.hpp>
#include <memory>
class Queue : public ICommand {
public:
Queue(dpp::snowflake Id);
Queue(std::shared_ptr<BumbleCeepp> Bot);
void operator()(const dpp::slashcommand_t& Event) {}
void operator()(std::list<std::string>& MusicQueue, const dpp::slashcommand_t& Event);
};
void operator()(std::list<FQueueElement>& MusicQueue, const dpp::slashcommand_t& Event);
private:
std::shared_ptr<BumbleCeepp> Bot;
};
#endif

15
include/FQueueElement.hpp Normal file
View File

@@ -0,0 +1,15 @@
#ifndef _FQUEUEELEMENT_HPP_
#define _FQUEUEELEMENT_HPP_
#include <string>
#include <dpp/dpp.h>
struct FQueueElement {
std::string title;
std::string description;
std::string FileName;
std::string thumbnail;
std::string duration;
dpp::snowflake guild_id;
};
#endif