From 177166856b6c9a39b3757bb623b0f19c3c9032eb Mon Sep 17 00:00:00 2001 From: Beshenka Date: Mon, 27 Jun 2022 20:36:29 +0300 Subject: [PATCH] bot: fix DeleteCommands --- bot.go | 16 +++------------- bot_test.go | 4 ++++ 2 files changed, 7 insertions(+), 13 deletions(-) diff --git a/bot.go b/bot.go index 8da821c..6182ee2 100644 --- a/bot.go +++ b/bot.go @@ -1473,20 +1473,10 @@ func (b *Bot) SetCommands(opts ...interface{}) error { } // DeleteCommands deletes the list of the bot's commands for the given scope and user language. -func (b *Bot) DeleteCommands(opts ...interface{}) ([]Command, error) { +func (b *Bot) DeleteCommands(opts ...interface{}) error { params := extractCommandsParams(opts...) - data, err := b.Raw("deleteMyCommands", params) - if err != nil { - return nil, err - } - - var resp struct { - Result []Command - } - if err := json.Unmarshal(data, &resp); err != nil { - return nil, wrapError(err) - } - return resp.Result, nil + _, err := b.Raw("deleteMyCommands", params) + return err } // Logout logs out from the cloud Bot API server before launching the bot locally. diff --git a/bot_test.go b/bot_test.go index 4296e46..031f393 100644 --- a/bot_test.go +++ b/bot_test.go @@ -596,6 +596,10 @@ func TestBot(t *testing.T) { cmds, err = b.Commands(CommandScope{Type: CommandScopeChat, ChatID: chatID}, "en") require.NoError(t, err) assert.Equal(t, orig2, cmds) + + require.NoError(t, b.DeleteCommands(CommandScope{Type: CommandScopeChat, ChatID: chatID}, "en")) + + require.NoError(t, b.DeleteCommands()) }) t.Run("CreateInviteLink", func(t *testing.T) {