Handle command errors differently than responses
Make them red.
This commit is contained in:
parent
27ef839725
commit
81e647c1c8
|
@ -105,15 +105,17 @@ func (cl *Client) NewMsg(data common.ClientData) {
|
||||||
|
|
||||||
response, err := commands.RunCommand(cmd, args, cl)
|
response, err := commands.RunCommand(cmd, args, cl)
|
||||||
if response != "" || err != nil {
|
if response != "" || err != nil {
|
||||||
|
msgType := common.MsgCommandResponse
|
||||||
respText := response
|
respText := response
|
||||||
if err != nil {
|
if err != nil {
|
||||||
respText = err.Error()
|
respText = err.Error()
|
||||||
|
msgType = common.MsgCommandError
|
||||||
}
|
}
|
||||||
|
|
||||||
err := cl.SendChatData(common.NewChatMessage("", "",
|
err := cl.SendChatData(common.NewChatMessage("", "",
|
||||||
common.ParseEmotes(respText),
|
common.ParseEmotes(respText),
|
||||||
common.CmdlUser,
|
common.CmdlUser,
|
||||||
common.MsgCommandResponse))
|
msgType))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
common.LogErrorf("Error command results %v\n", err)
|
common.LogErrorf("Error command results %v\n", err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,7 +54,7 @@ var commands = &CommandControl{
|
||||||
return "", fmt.Errorf("Too many arguments!")
|
return "", fmt.Errorf("Too many arguments!")
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the caller is priviledged enough, they can change the color of another user
|
// If the caller is privileged enough, they can change the color of another user
|
||||||
if len(args) == 2 {
|
if len(args) == 2 {
|
||||||
if cl.CmdLevel == common.CmdlUser {
|
if cl.CmdLevel == common.CmdlUser {
|
||||||
return "", fmt.Errorf("You cannot change someone else's color. PeepoSus")
|
return "", fmt.Errorf("You cannot change someone else's color. PeepoSus")
|
||||||
|
|
|
@ -108,6 +108,9 @@ func (dc DataMessage) HTML() string {
|
||||||
case MsgCommandResponse:
|
case MsgCommandResponse:
|
||||||
return `<span class="command">` + dc.Message + `</span>`
|
return `<span class="command">` + dc.Message + `</span>`
|
||||||
|
|
||||||
|
case MsgCommandError:
|
||||||
|
return `<span class="commanderror">` + dc.Message + `</span>`
|
||||||
|
|
||||||
default:
|
default:
|
||||||
badge := ""
|
badge := ""
|
||||||
switch dc.Level {
|
switch dc.Level {
|
||||||
|
|
|
@ -65,5 +65,6 @@ const (
|
||||||
MsgServer // server message
|
MsgServer // server message
|
||||||
MsgError // something went wrong
|
MsgError // something went wrong
|
||||||
MsgNotice // Like MsgServer, but for mods and admins only.
|
MsgNotice // Like MsgServer, but for mods and admins only.
|
||||||
MsgCommandResponse // The response to a command
|
MsgCommandResponse // The response from command
|
||||||
|
MsgCommandError // The error response from command
|
||||||
)
|
)
|
||||||
|
|
|
@ -113,6 +113,10 @@ input[type=text] {
|
||||||
color: #B1B1B1;
|
color: #B1B1B1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.commanderror {
|
||||||
|
color: #e82222;
|
||||||
|
}
|
||||||
|
|
||||||
.notice,
|
.notice,
|
||||||
.command,
|
.command,
|
||||||
.announcement {
|
.announcement {
|
||||||
|
@ -345,4 +349,4 @@ input[type=text] {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
z-index: 99;
|
z-index: 99;
|
||||||
color: var(--var-contrast-color);
|
color: var(--var-contrast-color);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue