mirror of
				https://gitlab.com/Kwoth/nadekobot.git
				synced 2025-11-03 16:24:27 -05:00 
			
		
		
		
	OwnerId will be autofilled in creds.yml if it's missing at startup
This commit is contained in:
		@@ -313,10 +313,29 @@ public sealed class Bot
 | 
				
			|||||||
        await _commandService.AddModulesAsync(typeof(Bot).Assembly, Services);
 | 
					        await _commandService.AddModulesAsync(typeof(Bot).Assembly, Services);
 | 
				
			||||||
        // await _interactionService.AddModulesAsync(typeof(Bot).Assembly, Services);
 | 
					        // await _interactionService.AddModulesAsync(typeof(Bot).Assembly, Services);
 | 
				
			||||||
        IsReady = true;
 | 
					        IsReady = true;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        await EnsureBotOwnershipAsync();
 | 
				
			||||||
        _ = Task.Run(ExecuteReadySubscriptions);
 | 
					        _ = Task.Run(ExecuteReadySubscriptions);
 | 
				
			||||||
        Log.Information("Shard {ShardId} ready", Client.ShardId);
 | 
					        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()
 | 
					    private Task ExecuteReadySubscriptions()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        var readyExecutors = Services.GetServices<IReadyExecutor>();
 | 
					        var readyExecutors = Services.GetServices<IReadyExecutor>();
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user