chore: require redis connection for bot
This commit is contained in:
parent
52c9ca9d0e
commit
3e76fd8d28
@ -53,7 +53,6 @@ public class Init
|
|||||||
|
|
||||||
// initialize Redis
|
// initialize Redis
|
||||||
var redis = services.Resolve<RedisService>();
|
var redis = services.Resolve<RedisService>();
|
||||||
if (coreConfig.RedisAddr != null)
|
|
||||||
await redis.InitAsync(coreConfig);
|
await redis.InitAsync(coreConfig);
|
||||||
|
|
||||||
var cache = services.Resolve<IDiscordCache>();
|
var cache = services.Resolve<IDiscordCache>();
|
||||||
@ -67,7 +66,6 @@ public class Init
|
|||||||
await services.Resolve<IDatabase>().ApplyMigrations();
|
await services.Resolve<IDatabase>().ApplyMigrations();
|
||||||
|
|
||||||
// Clear shard status from Redis
|
// Clear shard status from Redis
|
||||||
if (redis.Connection != null)
|
|
||||||
await redis.Connection.GetDatabase().KeyDeleteAsync("pluralkit:shardstatus");
|
await redis.Connection.GetDatabase().KeyDeleteAsync("pluralkit:shardstatus");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -75,7 +73,6 @@ public class Init
|
|||||||
var bot = services.Resolve<Bot>();
|
var bot = services.Resolve<Bot>();
|
||||||
|
|
||||||
// Get bot status message from Redis
|
// 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
|
// Init the bot instance itself, register handlers and such to the client before beginning to connect
|
||||||
|
@ -52,12 +52,6 @@ public class ShardInfoService
|
|||||||
|
|
||||||
async Task Inner()
|
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 db = _redis.Connection.GetDatabase();
|
||||||
var redisInfo = await db.HashGetAsync("pluralkit::shardstatus", shard.ShardId);
|
var redisInfo = await db.HashGetAsync("pluralkit::shardstatus", shard.ShardId);
|
||||||
|
|
||||||
|
@ -8,7 +8,6 @@ public class RedisService
|
|||||||
|
|
||||||
public async Task InitAsync(CoreConfig config)
|
public async Task InitAsync(CoreConfig config)
|
||||||
{
|
{
|
||||||
if (config.RedisAddr != null)
|
|
||||||
Connection = await ConnectionMultiplexer.ConnectAsync(config.RedisAddr);
|
Connection = await ConnectionMultiplexer.ConnectAsync(config.RedisAddr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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:
|
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.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.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.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.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.
|
* `PluralKit.SentryUrl` *(optional)*: the [Sentry](https://sentry.io/welcome/) client key/DSN to report runtime errors to. If absent, disables Sentry integration.
|
||||||
|
Loading…
Reference in New Issue
Block a user