Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var DeleteCommand = cli.Command{ Name: "delete", Usage: "Delete webhook", Aliases: []string{"d"}, Action: func(c *cli.Context) error { client := *webhook.New(discord.WebhookID(c.Int("id")), c.String("token")) err := client.Delete() if err != nil { return err } return nil }, }
View Source
var GetCommand = cli.Command{ Name: "get", Usage: "Get webhook", Aliases: []string{"g"}, Action: func(c *cli.Context) error { client := *webhook.New(discord.WebhookID(c.Int("id")), c.String("token")) webhook, err := client.Get() if err != nil { return err } if c.Bool("json") { if !c.Bool("no-redact") { webhook.Token = "" } format := c.Bool("format") msg, err := util.StringifyObject(webhook, format) if err != nil { return err } fmt.Println(msg) return nil } return nil }, Flags: []cli.Flag{ &cli.BoolFlag{Name: "json", Usage: "output webhook object in json"}, &cli.BoolFlag{Name: "format", Usage: "format output"}, &cli.BoolFlag{Name: "no-redact", Usage: "don't redact sensitive data, e.g. webhook token"}, }, }
View Source
var ModifyCommand = cli.Command{ Name: "modify", Usage: "Modify webhook", Aliases: []string{"m"}, Action: func(c *cli.Context) error { client := *webhook.New(discord.WebhookID(c.Int("id")), c.String("token")) if len(c.String("payload")) > 0 { payload := c.String("payload") data := api.ModifyWebhookData{} json.Unmarshal([]byte(payload), &data) webhook, err := client.Modify(data) if c.Bool("json") { format := c.Bool("format") msg, err := util.StringifyObject(webhook, format) if err != nil { return err } fmt.Println(msg) return nil } return err } if len(c.String("username")) == 0 && len(c.String("avatar")) != 0 { return errors.New("username must be supplied along with avatar") } else if len(c.String("username")) == 0 { return errors.New("no username or avatar supplied") } data := api.ModifyWebhookData{ Name: option.NewString(c.String("username")), } if len(c.String("avatar")) > 0 { avatar, err := util.BuildImageFromContext(c) if err != nil { return err } data.Avatar = avatar } webhook, err := client.Modify(data) if err != nil { return err } if c.Bool("json") { format := c.Bool("format") msg, err := util.StringifyObject(webhook, format) if err != nil { return err } fmt.Println(msg) return nil } return nil }, Flags: []cli.Flag{ &cli.StringFlag{ Name: "username", Usage: "webhook username", Aliases: []string{"u"}, }, &cli.StringFlag{ Name: "avatar", Usage: "path to webhook avatar image", Aliases: []string{"a"}, TakesFile: true, }, &cli.StringFlag{ Name: "payload", Usage: "raw json payload", Aliases: []string{"p"}}, &cli.BoolFlag{Name: "json", Usage: "output webhook object in json"}, &cli.BoolFlag{Name: "format", Usage: "format output"}, }, }
View Source
var SelfCommand = cli.Command{ Name: "self", Usage: "Refer to webhook", Subcommands: []*cli.Command{ &GetCommand, &ModifyCommand, &DeleteCommand, }, }
Functions ¶
This section is empty.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.