Fix Backup and fix worker discord

This commit is contained in:
2024-07-22 03:20:13 +07:00
parent 3360e48f47
commit ab621554ce
5 changed files with 54 additions and 8 deletions

View File

@@ -173,15 +173,21 @@ namespace Managing.Application.ManageBot
return Enums.BotStatus.Down.ToString();
}
public Task<bool> DeleteBot(string botName)
public async Task<bool> DeleteBot(string botName)
{
if (_botTasks.TryRemove(botName, out _))
if (_botTasks.TryRemove(botName, out var botWrapper))
{
if (botWrapper.BotInstance is IBot bot)
{
await Task.Run(() =>
bot.Stop()); // Assuming Stop is an asynchronous process wrapped in Task.Run for synchronous methods
}
_botRepository.DeleteBotBackup(botName);
return Task.FromResult(true);
return true;
}
return Task.FromResult(false);
return false;
}
public Task<string> RestartBot(string botName)