refactor: add Channel::addSystemMessage function (#5500)
This commit is contained in:
@@ -1,10 +1,8 @@
|
||||
#include "controllers/commands/builtin/twitch/AddModerator.hpp"
|
||||
|
||||
#include "Application.hpp"
|
||||
#include "common/Channel.hpp"
|
||||
#include "controllers/accounts/AccountController.hpp"
|
||||
#include "controllers/commands/CommandContext.hpp"
|
||||
#include "messages/MessageBuilder.hpp"
|
||||
#include "providers/twitch/api/Helix.hpp"
|
||||
#include "providers/twitch/TwitchAccount.hpp"
|
||||
#include "providers/twitch/TwitchChannel.hpp"
|
||||
@@ -22,23 +20,22 @@ QString addModerator(const CommandContext &ctx)
|
||||
|
||||
if (ctx.twitchChannel == nullptr)
|
||||
{
|
||||
ctx.channel->addMessage(makeSystemMessage(
|
||||
"The /mod command only works in Twitch channels."));
|
||||
ctx.channel->addSystemMessage(
|
||||
"The /mod command only works in Twitch channels.");
|
||||
return "";
|
||||
}
|
||||
if (ctx.words.size() < 2)
|
||||
{
|
||||
ctx.channel->addMessage(makeSystemMessage(
|
||||
ctx.channel->addSystemMessage(
|
||||
"Usage: \"/mod <username>\" - Grant moderator status to a "
|
||||
"user. Use \"/mods\" to list the moderators of this channel."));
|
||||
"user. Use \"/mods\" to list the moderators of this channel.");
|
||||
return "";
|
||||
}
|
||||
|
||||
auto currentUser = getIApp()->getAccounts()->twitch.getCurrent();
|
||||
if (currentUser->isAnon())
|
||||
{
|
||||
ctx.channel->addMessage(
|
||||
makeSystemMessage("You must be logged in to mod someone!"));
|
||||
ctx.channel->addSystemMessage("You must be logged in to mod someone!");
|
||||
return "";
|
||||
}
|
||||
|
||||
@@ -52,10 +49,10 @@ QString addModerator(const CommandContext &ctx)
|
||||
getHelix()->addChannelModerator(
|
||||
twitchChannel->roomId(), targetUser.id,
|
||||
[channel, targetUser] {
|
||||
channel->addMessage(makeSystemMessage(
|
||||
channel->addSystemMessage(
|
||||
QString("You have added %1 as a moderator of this "
|
||||
"channel.")
|
||||
.arg(targetUser.displayName)));
|
||||
.arg(targetUser.displayName));
|
||||
},
|
||||
[channel, targetUser](auto error, auto message) {
|
||||
QString errorMessage =
|
||||
@@ -116,13 +113,13 @@ QString addModerator(const CommandContext &ctx)
|
||||
}
|
||||
break;
|
||||
}
|
||||
channel->addMessage(makeSystemMessage(errorMessage));
|
||||
channel->addSystemMessage(errorMessage);
|
||||
});
|
||||
},
|
||||
[channel{ctx.channel}, target] {
|
||||
// Equivalent error from IRC
|
||||
channel->addMessage(
|
||||
makeSystemMessage(QString("Invalid username: %1").arg(target)));
|
||||
channel->addSystemMessage(
|
||||
QString("Invalid username: %1").arg(target));
|
||||
});
|
||||
|
||||
return "";
|
||||
|
||||
Reference in New Issue
Block a user