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 == "".
Describe the bug
The service wrappers return
&resp.InfoText, which is never nil, even on success whenInfoTextis"":monorepo/apps/twitch-bot/internal/service/service.go
Lines 170 to 176 in 35a83bd
(also the update/delete/alias wrappers in the same file, and in
monorepo/apps/discord-bot/internal/service/service.go
Lines 126 to 132 in 35a83bd
Callers read "infoText is not nil" as "there is a message for the user", so they reply with it and return early:
monorepo/apps/discord-bot/internal/command/addcommand.go
Lines 51 to 54 in 35a83bd
To Reproduce
!acmd hello world,!ucmd hello new,!dcmd hello,!acmda,!dcmdaall answerAlice,on success./acmdreturns before the new slash command is registered, so it only shows up after a restart./dcmdreturns 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
nilfrom the wrappers whenresp.InfoText == "".