Skip to content

Successful !acmd / !ucmd / !dcmd reply only "<name>, " and skip Discord slash command updates #718

Description

@emircan-sahin

Describe the bug
The service wrappers return &resp.InfoText, which is never nil, even on success when InfoText is "":

func (s *service) CreateCommand(ctx context.Context, commandName string, commandContent string, twitchChannelId string, createdBy string) (*string, error) {
resp, err := s.botCommandClient.CreateBotCommand(ctx, platform.TWITCH.String(), commandName, commandContent, twitchChannelId, createdBy)
if err != nil {
return nil, err
}
return &resp.InfoText, nil
}

(also the update/delete/alias wrappers in the same file, and in

func (s *service) CreateCommand(ctx context.Context, commandName string, commandContent string, discordServerId string, createdBy string) (*string, error) {
resp, err := s.botCommandClient.CreateBotCommand(ctx, platform.DISCORD.String(), commandName, commandContent, discordServerId, createdBy)
if err != nil {
return nil, err
}
return &resp.InfoText, nil
}
)

Callers read "infoText is not nil" as "there is a message for the user", so they reply with it and return early:

if infoText != nil {
ephemeralRespond(s, i, message.UserName+", "+*infoText)
return
}

To Reproduce

  • Twitch: !acmd hello world, !ucmd hello new, !dcmd hello, !acmda, !dcmda all answer Alice, on success.
  • Discord: /acmd returns before the new slash command is registered, so it only shows up after a restart. /dcmd returns before the deleted command's slash command is removed, so it stays in the guild.

Reproduced end to end over gRPC: !acmd hello world -> "Alice, ", same for ucmd and dcmd.

Expected behavior
The success message is sent, and on Discord the slash command is registered or removed.

Suggested fix
Return nil from the wrappers when resp.InfoText == "".

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions