diff --git a/src/NadekoBot/Bot.cs b/src/NadekoBot/Bot.cs index 00020ab3e..4ba39d834 100644 --- a/src/NadekoBot/Bot.cs +++ b/src/NadekoBot/Bot.cs @@ -313,10 +313,29 @@ public sealed class Bot await _commandService.AddModulesAsync(typeof(Bot).Assembly, Services); // await _interactionService.AddModulesAsync(typeof(Bot).Assembly, Services); IsReady = true; + + await EnsureBotOwnershipAsync(); _ = Task.Run(ExecuteReadySubscriptions); Log.Information("Shard {ShardId} ready", Client.ShardId); } + private async ValueTask EnsureBotOwnershipAsync() + { + try + { + if (_creds.OwnerIds.Count != 0) + return; + + Log.Information("Initializing Owner Id..."); + var info = await Client.GetApplicationInfoAsync(); + _credsProvider.ModifyCredsFile(x => x.OwnerIds = new[] { info.Owner.Id }); + } + catch (Exception ex) + { + Log.Warning("Getting application info failed: {ErrorMessage}", ex.Message); + } + } + private Task ExecuteReadySubscriptions() { var readyExecutors = Services.GetServices();