Countdown Timer in C#

Description

Run a countdown or countup timer and display in OBS, on a Stream Deck, or check elapsed/remaining time via Chat Command. Timer for Streamer.bot v0.2.3 should work for Twitch, YouTube, and Trovo

Import Code

countdownTimerv2.0.6.sb (14.6 KB)
timer_v0.2.3-3.sb (beta) (19.9 KB)

Installation

  1. Download the sb file
  2. In Streamer.bot in select Import from the top left.
  3. Find the sb file you downloaded and drag and drop into the Import String box of the Import dialog

Imported commands are disabled by default as a security measure. Review each command’s permissions before enabling each one.

In OBS

  1. Add a scene called [NS] Timer
  2. In the scene [NS] Timer, add a Text Source called [TS] Timer

You can add the scene [NS] Timer as a source in any scene you want to display the timer.

In Streamer.bot

1. In the Timer Code subaction: Edit the Execute Code (Countdown Timer v2) subaction
2. Click the Find Refs near the bottom of the window. This should add the Streamer.bot.Common.dll reference file located in your local Streamer.bot folder.
image
3. Click the Compile and make sure you see Compiled successfully!
image
4. Click Save and Compile

As of Streamer.bot v0.2.3, the steps above are unnecessary.

Configuration

Settings

Settings are located in the Timer Settings action.

OBS Settings Default Value Description
timerCountdownObsConnection 0 The index of your OBS connection you will use for displaying the timer in OBS
timerCountdownScene [NS] Timer Match the name of the nested scene created to display the timer text source
timerCountdownSource [TS] Timer Match the name of the text source created to display the timer
Chat Settings Default Value Description
sendAsBot True Any actions using the SendMessageToPlatformAction method will use this to decide to send a message as the bot account or not
sendAllPlatforms True Any actions using the SendMessageToPlatformAction method will use this to send a message to all platforms that have used the timer actions (Twitch, YouTube, Trovo)
(Optional) Stream Deck Settings Default Value Description
streamDeckTimer False Set to true if you want to update a Stream Deck button with the remaining time in the timer
streamDeckButtonId `` Set to the button ID of your Stream Deck button. You can get this by going to your Stream Deck application, creating a Streamer.bot Action button, and clicking the copy icon next to the Button ID.
  • If you want to be able to start the timer from the Stream Deck Button, assign the action to the Timer Start action, then add an argument with settings:
Type Name Value
String value Number of minutes to set the timer to start

image

Other actions with configuration

These settings apply to these actions: Timer Cancel, Timer Pause, and Timer Done

  • Under Chat Settings, set argument message to what you want to send to chat
  • Under OBS, set argument obsText to what you want to display in the OBS Text Source

image

Commands

Imported commands are disabled by default as a security measure. Review each command’s permissions before enabling each one.

Command Action Usage Explanation
!timer Timer Configuration and Start !timer duration Makes timer visible and starts the timer to the number specified in the command. You can use !timer -0.02 if you want the timer to count up.
!timeradd TimerAdd X Minutes !timeradd duration Adds your desired number of minutes to the timer.
!timercancel Timer Cancel !timercancel Stops the timer, then hides the text source. Must type it in twice to confirm.
!timerpause Timer Pause !timerpause Pause the timer
!timerresume Timer Resume !timerresume Resume the timer
!timerelapsed Timer Check Elapsed !timerelapsed This will display the elapsed time in Twitch chat
!timerremaining Timer Check Remaining !timerremaining This will display the remaining time in Twitch chat
!timershow Timer Countdown Action Group Enable !timershow This will make the text source visible in OBS
!timerhide Timer Countdown Action Group Disable !timerhide This will make the text source hidden in OBS

Duration can use the following syntax:
d for days, h for hours, m for minutes, s for seconds
Examples: 5d4h3m, 1h30m, 5m, 1h
1h30m or 90m should also work as equivalents.
A timer value set to up will initiate a count up timer instead of countdown.

6 Likes

Refactored some of the code for v0.2.3. I’ve only tested it with my own build, so reply if something is not working.

1 Like

Fixed some bugs. Added a way to configure the way some actions change the timer display in OBS (timer cancel, timer pause, timer done).