From 090259a6b4ca2ae3f70c68800c7ebf54f9058158 Mon Sep 17 00:00:00 2001 From: diamondburned Date: Wed, 14 Oct 2020 23:28:50 -0700 Subject: [PATCH] Bumped cchat --- go.mod | 2 +- go.sum | 2 ++ internal/discord/channel/commands/commands.go | 29 ++++++++++++++++++- 3 files changed, 31 insertions(+), 2 deletions(-) diff --git a/go.mod b/go.mod index 8abd893..63c85bc 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.14 require ( github.com/diamondburned/arikawa v1.3.0 - github.com/diamondburned/cchat v0.3.5 + github.com/diamondburned/cchat v0.3.7 github.com/diamondburned/ningen v0.1.1-0.20200820222640-35796f938a58 github.com/dustin/go-humanize v1.0.0 github.com/go-test/deep v1.0.7 diff --git a/go.sum b/go.sum index 45fbf36..f0d9613 100644 --- a/go.sum +++ b/go.sum @@ -92,6 +92,8 @@ github.com/diamondburned/cchat v0.3.4 h1:9JvcIrmy00cZMc2acfTSARTEzdtrSOqeIz/iYjH github.com/diamondburned/cchat v0.3.4/go.mod h1:IlMtF+XIvAJh0GL/2yFdf0/34w+Hdy5A1GgvSwAXtQI= github.com/diamondburned/cchat v0.3.5 h1:6rweOEmFLJUlrC98sLFwUUp9H+GWhVgtEqW5suF+J/o= github.com/diamondburned/cchat v0.3.5/go.mod h1:IlMtF+XIvAJh0GL/2yFdf0/34w+Hdy5A1GgvSwAXtQI= +github.com/diamondburned/cchat v0.3.6 h1:at9bnxlABa3TGscra/cRq/ASsmJh6GCdQ0vnCD91tDk= +github.com/diamondburned/cchat v0.3.6/go.mod h1:IlMtF+XIvAJh0GL/2yFdf0/34w+Hdy5A1GgvSwAXtQI= github.com/diamondburned/ningen v0.1.1-0.20200621014632-6babb812b249 h1:yP7kJ+xCGpDz6XbcfACJcju4SH1XDPwlrvbofz3lP8I= github.com/diamondburned/ningen v0.1.1-0.20200621014632-6babb812b249/go.mod h1:xW9hpBZsGi8KpAh10TyP+YQlYBo+Xc+2w4TR6N0951A= github.com/diamondburned/ningen v0.1.1-0.20200708085949-b64e350f3b8c h1:3h/kyk6HplYZF3zLi106itjYJWjbuMK/twijeGLEy2M= diff --git a/internal/discord/channel/commands/commands.go b/internal/discord/channel/commands/commands.go index c7053a3..a1f1ecc 100644 --- a/internal/discord/channel/commands/commands.go +++ b/internal/discord/channel/commands/commands.go @@ -39,7 +39,7 @@ func (cmds Commands) Run(ch *shared.Channel, words []string) ([]byte, error) { return nil, fmt.Errorf("unknown command %q, refer to help", words[0]) } - return cmd.RunFunc(ch, words) + return cmd.RunFunc(ch, words[1:]) } // FindExact finds the exact command. It returns a pointer to the command @@ -93,6 +93,7 @@ var World = Commands{ return nil, err } + embed.Description = fs.Arg(0) embed.Color = discord.Color(color) m, err := ch.State.SendEmbed(ch.ID, embed) @@ -159,6 +160,32 @@ var World = Commands{ return renderJSON(p) }, }, + { + Name: "member", + Args: Arguments{"mention:user"}, + Desc: "Print JSON of a member/user's member state", + RunFunc: func(ch *shared.Channel, argv []string) ([]byte, error) { + if err := assertArgc(argv, 1); err != nil { + return nil, err + } + + if !ch.GuildID.IsValid() { + return nil, errors.New("channel not in guild") + } + + var user arguments.UserMention + if err := user.Parse(argv[0]); err != nil { + return nil, err + } + + m, err := ch.State.Member(ch.GuildID, user.ID()) + if err != nil { + return nil, err + } + + return renderJSON(m) + }, + }, } func assertArgc(argv []string, argc int) error {