Browse Source

Add validation for disappearing-timer command

Tulir Asokan 3 years ago
parent
commit
e9f01b81d5
1 changed files with 6 additions and 1 deletions
  1. 6 1
      commands.go

+ 6 - 1
commands.go

@@ -1143,10 +1143,15 @@ var cmdDisappearingTimer = &commands.FullHandler{
 		Description: "Set future messages in the room to disappear after the given time.",
 		Description: "Set future messages in the room to disappear after the given time.",
 		Args:        "<off/1d/7d/90d>",
 		Args:        "<off/1d/7d/90d>",
 	},
 	},
-	RequiresLogin: true,
+	RequiresLogin:  true,
+	RequiresPortal: true,
 }
 }
 
 
 func fnDisappearingTimer(ce *WrappedCommandEvent) {
 func fnDisappearingTimer(ce *WrappedCommandEvent) {
+	if len(ce.Args) == 0 {
+		ce.Reply("**Usage:** `disappearing-timer <off/1d/7d/90d>`")
+		return
+	}
 	duration, ok := whatsmeow.ParseDisappearingTimerString(ce.Args[0])
 	duration, ok := whatsmeow.ParseDisappearingTimerString(ce.Args[0])
 	if !ok {
 	if !ok {
 		ce.Reply("Invalid timer '%s'", ce.Args[0])
 		ce.Reply("Invalid timer '%s'", ce.Args[0])