Skip to content

Commit 1ffde8f

Browse files
committed
feat: add configurable update interval
1 parent c0e4f2c commit 1ffde8f

3 files changed

Lines changed: 17 additions & 1 deletion

File tree

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
namespace Stopwatch.Configuration;
2+
3+
public sealed class BotConfiguration
4+
{
5+
/// <summary>
6+
/// Gets the interval, in seconds, at which the bot will update the slowmode rate limit for all channels.
7+
/// </summary>
8+
/// <value>The update interval.</value>
9+
public int UpdateInterval { get; set; } = 2000;
10+
}

Stopwatch/Services/ConfigurationService.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,12 @@ public ConfigurationService(IConfiguration configuration)
2121
_configuration = configuration;
2222
}
2323

24+
/// <summary>
25+
/// Gets the global bot configuration.
26+
/// </summary>
27+
/// <value>The bot configuration.</value>
28+
public BotConfiguration BotConfiguration => _configuration.Get<BotConfiguration>() ?? new BotConfiguration();
29+
2430
/// <summary>
2531
/// Gets the bot configuration for the specified guild.
2632
/// </summary>

Stopwatch/Services/SlowModeService.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public SlowModeService(ILogger<SlowModeService> logger,
5151
_discordClient = discordClient;
5252

5353
_updateTimer.Enabled = false;
54-
_updateTimer.Interval = 10000;
54+
_updateTimer.Interval = configurationService.BotConfiguration.UpdateInterval;
5555
_updateTimer.Elapsed += UpdateTimerOnElapsed;
5656
}
5757

0 commit comments

Comments
 (0)