mirror of
https://github.com/diamondburned/arikawa.git
synced 2024-11-27 17:23:00 +00:00
Bot: Fixed bug where RawArguments still have the command
This commit is contained in:
parent
4a14c4d059
commit
90bf9d74e3
|
@ -380,6 +380,8 @@ func (ctx *Context) callMessageCreate(mc *gateway.MessageCreateEvent) error {
|
|||
|
||||
// Seek to the string.
|
||||
if i := strings.Index(content, seekTo); i > -1 {
|
||||
// Seek past the substring.
|
||||
i += len(seekTo)
|
||||
content = strings.TrimSpace(content[i:])
|
||||
}
|
||||
|
||||
|
|
|
@ -62,7 +62,7 @@ func TestSubcommandPlumb(t *testing.T) {
|
|||
t.Fatal("Normal method called for hasPlumb")
|
||||
}
|
||||
|
||||
if p.Plumbed != "hasPlumb test command" {
|
||||
if p.Plumbed != "test command" {
|
||||
t.Fatal("Unexpected custom argument for plumbed:", p.Plumbed)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,14 +19,12 @@ type testc struct {
|
|||
Typed bool
|
||||
}
|
||||
|
||||
func (t *testc) MーBumpCounter(interface{}) error {
|
||||
func (t *testc) MーBumpCounter(interface{}) {
|
||||
t.Counter++
|
||||
return nil
|
||||
}
|
||||
|
||||
func (t *testc) GetCounter(_ *gateway.MessageCreateEvent) error {
|
||||
func (t *testc) GetCounter(_ *gateway.MessageCreateEvent) {
|
||||
t.Return <- strconv.FormatUint(t.Counter, 10)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (t *testc) Send(_ *gateway.MessageCreateEvent, args ...string) error {
|
||||
|
@ -34,32 +32,31 @@ func (t *testc) Send(_ *gateway.MessageCreateEvent, args ...string) error {
|
|||
return errors.New("oh no")
|
||||
}
|
||||
|
||||
func (t *testc) Custom(_ *gateway.MessageCreateEvent, c *customManualParsed) error {
|
||||
func (t *testc) Custom(_ *gateway.MessageCreateEvent, c *customManualParsed) {
|
||||
t.Return <- c.args
|
||||
return nil
|
||||
}
|
||||
|
||||
func (t *testc) Variadic(_ *gateway.MessageCreateEvent, c ...*customParsed) error {
|
||||
func (t *testc) Variadic(_ *gateway.MessageCreateEvent, c ...*customParsed) {
|
||||
t.Return <- c[len(c)-1]
|
||||
return nil
|
||||
}
|
||||
|
||||
func (t *testc) TrailCustom(_ *gateway.MessageCreateEvent, s string, c *customManualParsed) error {
|
||||
func (t *testc) TrailCustom(_ *gateway.MessageCreateEvent, s string, c *customManualParsed) {
|
||||
t.Return <- c.args
|
||||
return nil
|
||||
}
|
||||
|
||||
func (t *testc) Content(_ *gateway.MessageCreateEvent, c RawArguments) {
|
||||
t.Return <- c
|
||||
}
|
||||
|
||||
func (t *testc) NoArgs(_ *gateway.MessageCreateEvent) error {
|
||||
return errors.New("passed")
|
||||
}
|
||||
|
||||
func (t *testc) Noop(_ *gateway.MessageCreateEvent) error {
|
||||
return nil
|
||||
func (t *testc) Noop(_ *gateway.MessageCreateEvent) {
|
||||
}
|
||||
|
||||
func (t *testc) OnTyping(_ *gateway.TypingStartEvent) error {
|
||||
func (t *testc) OnTyping(_ *gateway.TypingStartEvent) {
|
||||
t.Typed = true
|
||||
return nil
|
||||
}
|
||||
|
||||
func TestNewContext(t *testing.T) {
|
||||
|
@ -194,6 +191,15 @@ func TestContext(t *testing.T) {
|
|||
}
|
||||
})
|
||||
|
||||
t.Run("call command rawarguments", func(t *testing.T) {
|
||||
ctx.HasPrefix = NewPrefix("!")
|
||||
expects := RawArguments("just things")
|
||||
|
||||
if err := testReturn(expects, "!content just things"); err != nil {
|
||||
t.Fatal("Unexpected call error:", err)
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("call command custom manual parser", func(t *testing.T) {
|
||||
ctx.HasPrefix = NewPrefix("!")
|
||||
expects := []string{"arg1", ":)"}
|
||||
|
|
|
@ -29,7 +29,7 @@ func TestSubcommand(t *testing.T) {
|
|||
}
|
||||
|
||||
// !!! CHANGE ME
|
||||
if len(sub.Commands) != 7 {
|
||||
if len(sub.Commands) != 8 {
|
||||
t.Fatal("invalid ctx.commands len", len(sub.Commands))
|
||||
}
|
||||
|
||||
|
@ -59,7 +59,7 @@ func TestSubcommand(t *testing.T) {
|
|||
t.Fatal("expected 0 arguments, got non-zero")
|
||||
}
|
||||
|
||||
case "noop", "getCounter", "variadic", "trailCustom":
|
||||
case "noop", "getCounter", "variadic", "trailCustom", "content":
|
||||
// Found, but whatever
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue