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)
|
||||
if response != "" || err != nil {
|
||||
msgType := common.MsgCommandResponse
|
||||
respText := response
|
||||
if err != nil {
|
||||
respText = err.Error()
|
||||
msgType = common.MsgCommandError
|
||||
}
|
||||
|
||||
err := cl.SendChatData(common.NewChatMessage("", "",
|
||||
common.ParseEmotes(respText),
|
||||
common.CmdlUser,
|
||||
common.MsgCommandResponse))
|
||||
msgType))
|
||||
if err != nil {
|
||||
common.LogErrorf("Error command results %v\n", err)
|
||||
}
|
||||
|
|
|
@ -54,7 +54,7 @@ var commands = &CommandControl{
|
|||
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 cl.CmdLevel == common.CmdlUser {
|
||||
return "", fmt.Errorf("You cannot change someone else's color. PeepoSus")
|
||||
|
|
|
@ -108,6 +108,9 @@ func (dc DataMessage) HTML() string {
|
|||
case MsgCommandResponse:
|
||||
return `<span class="command">` + dc.Message + `</span>`
|
||||
|
||||
case MsgCommandError:
|
||||
return `<span class="commanderror">` + dc.Message + `</span>`
|
||||
|
||||
default:
|
||||
badge := ""
|
||||
switch dc.Level {
|
||||
|
|
|
@ -65,5 +65,6 @@ const (
|
|||
MsgServer // server message
|
||||
MsgError // something went wrong
|
||||
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;
|
||||
}
|
||||
|
||||
.commanderror {
|
||||
color: #e82222;
|
||||
}
|
||||
|
||||
.notice,
|
||||
.command,
|
||||
.announcement {
|
||||
|
@ -345,4 +349,4 @@ input[type=text] {
|
|||
position: absolute;
|
||||
z-index: 99;
|
||||
color: var(--var-contrast-color);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue