Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions _examples/command/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,15 @@ Program executed successfully.

**I am receiving `Invalid interaction application command` from Discord when I send an interaction.**

Discord propagates registered Global Application Commands. As a result, it can take time to add or update a Global Application Command. In addition, the user's client must reload the commands that are available to them, so that the user's client selects the new propagated Global Application Command _(with a new ID and Token)_. In contrast, Guild Application Commands _(registered via `CreateGuildApplicationCommand`)_ are updated instantly. Due to this behavior, use Guild Application Commands to test your application without waiting for propagation. For more information, read the [Discord API Documentation](https://discord.com/developers/docs/interactions/application-commands#registering-a-command).
Discord propagates registered Global Application Commands. So, it can take time to add or update a Global Application Command. In addition, the user's client must reload the commands that are available to them, so that the user's client selects the new propagated Global Application Command _(with a new ID and Token)_. In contrast, Guild Application Commands _(registered via `CreateGuildApplicationCommand`)_ are updated instantly. Due to this behavior, use Guild Application Commands to test your application without waiting for propagation. For more information, read the [Discord API Documentation](https://discord.com/developers/docs/interactions/application-commands#registering-a-command).

**I am receiving a nil pointer dereference when the Bot's Application Command is used in a DM or Guild.**

When an Application Command is used in a direct message, the `Interaction.User` field is provided, while the `Interaction.Member` is **NOT**. When an Application Command is used in a guild, the `Interaction.Member` field is provided, while the `Interaction.User` is **NOT**. For the sake of simplicity, these examples assume that you will use your command in a Direct Message Channel. To protect against this behavior in production-level code, ensure that the `Interaction.User` or `Interaction.Member` is `!= nil` before referencing their fields.
These examples create commands for usage in a Direct Message Channel. Confirm the `Interaction.User` or `Interaction.Member` is `!= nil` before referencing their fields to protect against this behavior in production-level code.

_Here is more information about this behavior._

When an Application Command is used in a direct message, the `Interaction.User` field is provided, while the `Interaction.Member` is **NOT**.

When an Application Command is used in a guild, the `Interaction.Member` field is provided, while the `Interaction.User` is **NOT**.

2 changes: 1 addition & 1 deletion _examples/command/autocomplete/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ func main() {

// Add an event handler to the bot.
//
// ensure that the event handler is added to the bot.
// confirm the event handler is added to the bot.
if err := bot.Handle(disgo.FlagGatewayEventNameInteractionCreate, func(i *disgo.InteractionCreate) {
log.Println("Received interaction.")

Expand Down
2 changes: 1 addition & 1 deletion _examples/command/followup/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func main() {

// Add an event handler to the bot.
//
// ensure that the event handler is added to the bot.
// confirm the event handler is added to the bot.
if err := bot.Handle(disgo.FlagGatewayEventNameInteractionCreate, func(i *disgo.InteractionCreate) {
log.Printf("followup called by %s.", i.Interaction.User.Username)

Expand Down
2 changes: 1 addition & 1 deletion _examples/command/localization/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ func main() {

// Add an event handler to the bot.
//
// ensure that the event handler is added to the bot.
// confirm the event handler is added to the bot.
if err := bot.Handle(disgo.FlagGatewayEventNameInteractionCreate, func(i *disgo.InteractionCreate) {
log.Printf("hello called by %s.", i.Interaction.User.Username)

Expand Down
2 changes: 1 addition & 1 deletion _examples/command/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ func main() {

// Add an event handler to the bot.
//
// ensure that the event handler is added to the bot.
// confirm the event handler is added to the bot.
if err := bot.Handle(disgo.FlagGatewayEventNameInteractionCreate, func(i *disgo.InteractionCreate) {
log.Printf("main called by %s.", i.Interaction.User.Username)

Expand Down
2 changes: 1 addition & 1 deletion _examples/command/subcommand/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ func main() {

// Add an event handler to the bot.
//
// ensure that the event handler is added to the bot.
// confirm the event handler is added to the bot.
if err := bot.Handle(disgo.FlagGatewayEventNameInteractionCreate, func(i *disgo.InteractionCreate) {
log.Printf("calculate called by %s.", i.Interaction.User.Username)

Expand Down
2 changes: 1 addition & 1 deletion _examples/image/avatar/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func main() {
// parse the command line flags.
flag.Parse()

// ensure that the program has the necessary data to succeed.
// confirm the program has the necessary data to succeed.
if token == "" {
fmt.Println("The bot's token must be set, but is currently empty.")

Expand Down
4 changes: 2 additions & 2 deletions _examples/message/components/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func main() {
// parse the command line flags.
flag.Parse()

// ensure that the program has the necessary data to succeed.
// confirm the program has the necessary data to succeed.
if token == "" {
log.Println("The bot's token must be set, but is currently empty.")

Expand All @@ -46,7 +46,7 @@ func main() {
Config: disgo.DefaultConfig(),
}

// ensure that the bot has access to the channel.
// confirm the bot has access to the channel.
//
// This is useful for the validation of this program, but unnecessary.
getChannelRequest := disgo.GetChannel{ChannelID: *channelID}
Expand Down
4 changes: 2 additions & 2 deletions _examples/message/send/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func main() {
// parse the command line flags.
flag.Parse()

// ensure that the program has the necessary data to succeed.
// confirm the program has the necessary data to succeed.
if token == "" {
log.Println("The bot's token must be set, but is currently empty.")

Expand Down Expand Up @@ -69,7 +69,7 @@ func main() {
Config: disgo.DefaultConfig(),
}

// ensure that the bot has access to the channel.
// confirm the bot has access to the channel.
//
// This is useful for the validation of this program, but unnecessary.
getChannelRequest := disgo.GetChannel{ChannelID: *channelID}
Expand Down
Loading
Loading