Skip to content

Commit

Permalink
Fix 2 minor "bugs"
Browse files Browse the repository at this point in the history
Change empty string comparison to string.isNullOrEmpty and move video format check before empty time parameter check
  • Loading branch information
HEJOK254 authored Jun 17, 2024
1 parent d522e35 commit 8220550
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions Commands/Modules/VideoUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,17 @@ public async Task TrimVideoAsync(
// Achknowledge the command
await DeferAsync(ephemeral);

// There is a similar check for the TimeSpan library below, but this it to avoid
if (trimStartString == "" && trimEndString == "")
// Reject incorrect video formats
if (video.ContentType != "video/mp4")
{
await FollowupAsync("You must provide a start or end time to trim the video.", ephemeral: true);
await FollowupAsync("Invalid video format. Please provide an MP4 file.", ephemeral: true);
return;
}

// Reject incorrect video formats
if (video.ContentType != "video/mp4")
// There is a similar check for the TimeSpan library below, but this it to avoid
if (string.IsNullOrEmpty(trimStartString) && string.IsNullOrEmpty(trimEndString))
{
await FollowupAsync("Invalid video format. Please provide an MP4 file.", ephemeral: true);
await FollowupAsync("You must provide a start or end time to trim the video.", ephemeral: true);
return;
}

Expand Down Expand Up @@ -171,4 +171,4 @@ public static TimeSpan TimeSpanFromHMS(string input)
// Create and return the TimeSpan object
return new TimeSpan(days: 0, hours, minutes, seconds, milliseconds);
}
}
}

0 comments on commit 8220550

Please sign in to comment.