Update p command to use error channel
This commit is contained in:
parent
73a5bad338
commit
c371888daa
@ -7,7 +7,7 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
func pCommand(ctx disgoman.Context, args []string) error {
|
func pCommand(ctx disgoman.Context, args []string) {
|
||||||
input := strings.Join(args, "")
|
input := strings.Join(args, "")
|
||||||
const LENGTH = 1999
|
const LENGTH = 1999
|
||||||
var mem [LENGTH]byte
|
var mem [LENGTH]byte
|
||||||
@ -57,8 +57,12 @@ func pCommand(ctx disgoman.Context, args []string) error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
ctx.Send(fmt.Sprintf("Invalid Character: %v", input[i]))
|
ctx.ErrorChannel <- disgoman.CommandError{
|
||||||
return errors.New("invalid character")
|
Context: ctx,
|
||||||
|
Message: fmt.Sprintf("Invalid Character: %v", input[i]),
|
||||||
|
Error: errors.New("invalid character"),
|
||||||
|
}
|
||||||
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var out []byte
|
var out []byte
|
||||||
@ -67,11 +71,14 @@ func pCommand(ctx disgoman.Context, args []string) error {
|
|||||||
out = append(out, i)
|
out = append(out, i)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fmt.Println(out)
|
|
||||||
_, err := ctx.Send(string(out))
|
_, err := ctx.Send(string(out))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println(err)
|
ctx.ErrorChannel <- disgoman.CommandError{
|
||||||
return err
|
Context: ctx,
|
||||||
|
Message: "Couldn't send results",
|
||||||
|
Error: err,
|
||||||
}
|
}
|
||||||
return nil
|
return
|
||||||
|
}
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user