Add /setgame and /settitle (#2534)
Co-authored-by: pajlada <rasmus.karlsson@pajlada.com>
This commit is contained in:
@@ -643,7 +643,85 @@ void CommandController::initialize(Settings &, Paths &paths)
|
||||
getApp()->windows->getMainWindow().getNotebook().getSelectedPage());
|
||||
|
||||
currentPage->getSelectedSplit()->getChannelView().clearMessages();
|
||||
return "";
|
||||
});
|
||||
|
||||
this->registerCommand("/settitle", [](const QStringList &words,
|
||||
ChannelPtr channel) {
|
||||
if (words.size() < 2)
|
||||
{
|
||||
channel->addMessage(
|
||||
makeSystemMessage("Usage: /settitle <stream title>."));
|
||||
return "";
|
||||
}
|
||||
if (auto twitchChannel = dynamic_cast<TwitchChannel *>(channel.get()))
|
||||
{
|
||||
auto status = twitchChannel->accessStreamStatus();
|
||||
auto title = words.mid(1).join(" ");
|
||||
getHelix()->updateChannel(
|
||||
twitchChannel->roomId(), "", "", title,
|
||||
[channel, title](NetworkResult) {
|
||||
channel->addMessage(makeSystemMessage(
|
||||
QString("Updated title to %1").arg(title)));
|
||||
},
|
||||
[channel] {
|
||||
channel->addMessage(
|
||||
makeSystemMessage("Title update failed! Are you "
|
||||
"missing the required scope?"));
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
channel->addMessage(makeSystemMessage(
|
||||
"Unable to set title of non-Twitch channel."));
|
||||
}
|
||||
return "";
|
||||
});
|
||||
this->registerCommand("/setgame", [](const QStringList &words,
|
||||
ChannelPtr channel) {
|
||||
if (words.size() < 2)
|
||||
{
|
||||
channel->addMessage(
|
||||
makeSystemMessage("Usage: /setgame <stream game>."));
|
||||
return "";
|
||||
}
|
||||
if (auto twitchChannel = dynamic_cast<TwitchChannel *>(channel.get()))
|
||||
{
|
||||
getHelix()->fetchGames(
|
||||
QStringList(), {words.mid(1).join(" ")},
|
||||
[channel, twitchChannel](std::vector<HelixGame> games) {
|
||||
if (games.size() == 0)
|
||||
{
|
||||
channel->addMessage(
|
||||
makeSystemMessage("Game not found."));
|
||||
}
|
||||
else // 0 or 1 games
|
||||
{
|
||||
auto status = twitchChannel->accessStreamStatus();
|
||||
getHelix()->updateChannel(
|
||||
twitchChannel->roomId(), games.at(0).id, "", "",
|
||||
[channel, games](NetworkResult) {
|
||||
channel->addMessage(makeSystemMessage(
|
||||
QString("Updated game to %1")
|
||||
.arg(games.at(0).name)));
|
||||
},
|
||||
[channel] {
|
||||
channel->addMessage(makeSystemMessage(
|
||||
"Game update failed! Are you "
|
||||
"missing the required scope?"));
|
||||
});
|
||||
}
|
||||
},
|
||||
[channel] {
|
||||
channel->addMessage(
|
||||
makeSystemMessage("Failed to look up game."));
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
channel->addMessage(
|
||||
makeSystemMessage("Unable to set game of non-Twitch channel."));
|
||||
}
|
||||
return "";
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user