Class BotConfigurationService
- Namespace
- FishMMO.DiscordBot.Services
- Assembly
- FishMMO-DiscordBot.dll
Manages loading and saving of persistent bot configuration, including the dynamic channel states mapping and persistent bot data (linked accounts, bridge bans, muted zones). All inner dictionaries use ConcurrentDictionary<TKey, TValue> for thread safety.
public class BotConfigurationService
- Inheritance
-
BotConfigurationService
- Inherited Members
Constructors
BotConfigurationService(ILogger<BotConfigurationService>)
Initializes a new instance of the BotConfigurationService class.
public BotConfigurationService(ILogger<BotConfigurationService> logger)
Parameters
loggerILogger<BotConfigurationService>Logger instance.
Methods
LoadConfigurationsAsync()
Loads dynamic channel state from the JSON configuration file on disk. If the file does not exist or is invalid, starts with an empty state.
public Task LoadConfigurationsAsync()
Returns
SaveConfigurationsAsync()
Persists the current dynamic channel state to the JSON configuration file. Uses atomic write-to-temp-then-rename to prevent corruption on crash.
public Task SaveConfigurationsAsync()
Returns
SavePersistentDataAsync()
Saves the persistent bot data to disk.
public Task SavePersistentDataAsync()
Returns
UpdateDynamicChannelState(ulong, long, long, DynamicGameChatChannelState)
Updates or inserts a channel state entry for the given guild/world/scene combination. Thread-safe for concurrent access from multiple services.
public void UpdateDynamicChannelState(ulong guildId, long worldServerId, long sceneServerId, DynamicGameChatChannelState state)
Parameters
guildIdulongThe Discord guild ID.
worldServerIdlongThe game world server ID.
sceneServerIdlongThe game scene server ID.
stateDynamicGameChatChannelStateThe channel state to store.