diff --git a/PluralKit.Bot/Init.cs b/PluralKit.Bot/Init.cs index 066d0d16..9e882370 100644 --- a/PluralKit.Bot/Init.cs +++ b/PluralKit.Bot/Init.cs @@ -53,8 +53,7 @@ public class Init // initialize Redis var redis = services.Resolve(); - if (coreConfig.RedisAddr != null) - await redis.InitAsync(coreConfig); + await redis.InitAsync(coreConfig); var cache = services.Resolve(); if (cache is RedisDiscordCache) @@ -67,16 +66,14 @@ public class Init await services.Resolve().ApplyMigrations(); // Clear shard status from Redis - if (redis.Connection != null) - await redis.Connection.GetDatabase().KeyDeleteAsync("pluralkit:shardstatus"); + await redis.Connection.GetDatabase().KeyDeleteAsync("pluralkit:shardstatus"); } logger.Information("Initializing bot"); var bot = services.Resolve(); // Get bot status message from Redis - if (redis.Connection != null) - bot.CustomStatusMessage = await redis.Connection.GetDatabase().StringGetAsync("pluralkit:botstatus"); + bot.CustomStatusMessage = await redis.Connection.GetDatabase().StringGetAsync("pluralkit:botstatus"); // Init the bot instance itself, register handlers and such to the client before beginning to connect bot.Init(); diff --git a/PluralKit.Bot/Services/ShardInfoService.cs b/PluralKit.Bot/Services/ShardInfoService.cs index 41d1e47f..0defb23b 100644 --- a/PluralKit.Bot/Services/ShardInfoService.cs +++ b/PluralKit.Bot/Services/ShardInfoService.cs @@ -52,12 +52,6 @@ public class ShardInfoService async Task Inner() { - if (_redis.Connection == null) - { - _logger.Warning("Redis is disabled, shard connection status will be unavailable."); - return; - } - var db = _redis.Connection.GetDatabase(); var redisInfo = await db.HashGetAsync("pluralkit::shardstatus", shard.ShardId); diff --git a/PluralKit.Core/Services/RedisService.cs b/PluralKit.Core/Services/RedisService.cs index cd283f56..54f23b5e 100644 --- a/PluralKit.Core/Services/RedisService.cs +++ b/PluralKit.Core/Services/RedisService.cs @@ -8,8 +8,7 @@ public class RedisService public async Task InitAsync(CoreConfig config) { - if (config.RedisAddr != null) - Connection = await ConnectionMultiplexer.ConnectAsync(config.RedisAddr); + Connection = await ConnectionMultiplexer.ConnectAsync(config.RedisAddr); } private string LastMessageKey(ulong userId, ulong channelId) => $"user_last_message:{userId}:{channelId}"; diff --git a/README.md b/README.md index 84646fc3..81b05557 100644 --- a/README.md +++ b/README.md @@ -17,6 +17,7 @@ The configuration file needs to be placed in the bot's working directory (usuall The configuration file is in JSON format (albeit with a `.conf` extension). The following keys are available (using `.` to indicate a nested object level), bolded key names are required: * **`PluralKit.Bot.Token`**: the Discord bot token to connect with * **`PluralKit.Database`**: the URI of the database to connect to (in [ADO.NET Npgsql format](https://www.connectionstrings.com/npgsql/)) +* **`PluralKit.RedisAddr`**: the `host:port` of a Redis database to connect to * `PluralKit.Bot.Prefixes`: an array of command prefixes to use (default `["pk;", "pk!"]`). * **`PluralKit.Bot.ClientId`**: the ID of the bot's user account, used for calculating the bot's own permissions and for the link in `pk;invite`. * `PluralKit.SentryUrl` *(optional)*: the [Sentry](https://sentry.io/welcome/) client key/DSN to report runtime errors to. If absent, disables Sentry integration.