1
0
mirror of https://github.com/Rudi9719/kbtui.git synced 2026-03-22 02:57:23 +00:00

Fix crash from not supplying ID

This commit is contained in:
Gregory Rudolph
2019-10-04 13:20:24 -04:00
parent 5068fd62e1
commit b6e108f3f0

View File

@ -9,7 +9,7 @@ import (
func init() {
command := Command{
Cmd: []string{"delete", "del"},
Cmd: []string{"delete", "del", "-"},
Description: "$messageId - Delete a message by $messageId",
Help: "",
Exec: cmdDelete,
@ -18,7 +18,13 @@ func init() {
RegisterCommand(command)
}
func cmdDelete(cmd []string) {
messageID, _ := strconv.Atoi(cmd[1])
var messageID int
if len(cmd) > 1 {
messageID, _ = strconv.Atoi(cmd[1])
} else {
messageID = lastMessage.ID
}
chat := k.NewChat(channel)
_, err := chat.Delete(messageID)
if err != nil {