go into command manager
Signed-off-by: Aleksey Selihov <faumaray@gmail.com>
This commit is contained in:
1 parent
b94b634a87
commit
1153721546
19 files changed
+752
-229
No files matched your search
@@ -0,0 +1,51 @@
|
||||
#pragma once
|
||||
#include <Command/Interface.hpp>
|
||||
#include <charconv>
|
||||
#include <format>
|
||||
#include <ts6bot/MusicManager.hpp>
|
||||
|
||||
class Queue : public Command
|
||||
{
|
||||
public:
|
||||
|
||||
void execute(const CommandContext& ctx) override
|
||||
{
|
||||
if (ctx.musicManager.expired()) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto q = ctx.musicManager.lock()->getQueue();
|
||||
auto current = ctx.musicManager.lock()->getCurrent();
|
||||
|
||||
std::string str;
|
||||
if (current) {
|
||||
str =
|
||||
std::format("Now playing: [{}]({}) [{}]\n\n", current->name,
|
||||
current->shortUrl, current->length);
|
||||
}
|
||||
|
||||
if (q.empty() && str.empty()) {
|
||||
ctx.reply("Queue is empty.");
|
||||
return;
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < q.size(); ++i) {
|
||||
str += std::format("{}. [{}]({}) [{}]\n", i + 1, q[i].name,
|
||||
q[i].shortUrl, q[i].length);
|
||||
}
|
||||
ctx.reply(str);
|
||||
}
|
||||
std::string_view getDescription() const override
|
||||
{
|
||||
return "Shows the current queue.";
|
||||
}
|
||||
CommandCategory getCategory() const override
|
||||
{
|
||||
return CommandCategory::Music;
|
||||
}
|
||||
std::vector<std::string_view> getAliases() const override
|
||||
{
|
||||
return {"list", "q", "l"};
|
||||
}
|
||||
std::string_view getUsage() const override { return ""; }
|
||||
};
|
||||
Reference in new issue
Block a user