mirror of
				https://gitlab.com/Kwoth/nadekobot.git
				synced 2025-11-04 08:34:27 -05:00 
			
		
		
		
	- Possible small fix for .prune ratelimiting
- Use .WhenAll extension instead of Task.WhenAll in a few more places
This commit is contained in:
		@@ -46,7 +46,7 @@ public class PruneService : INService
 | 
			
		||||
                    await Task.WhenAll(Task.Delay(1000), channel.DeleteMessagesAsync(bulkDeletable));
 | 
			
		||||
 | 
			
		||||
                foreach (var group in singleDeletable.Chunk(5))
 | 
			
		||||
                    await Task.WhenAll(Task.Delay(1000), group.Select(x => x.DeleteAsync()).WhenAll());
 | 
			
		||||
                    await Task.WhenAll(Task.Delay(5000), group.Select(x => x.DeleteAsync()).WhenAll());
 | 
			
		||||
 | 
			
		||||
                //this isn't good, because this still work as if i want to remove only specific user's messages from the last
 | 
			
		||||
                //100 messages, Maybe this needs to be reduced by msgs.Length instead of 100
 | 
			
		||||
 
 | 
			
		||||
@@ -170,14 +170,14 @@ public sealed class SelfService : ILateExecutor, IReadyExecutor, INService
 | 
			
		||||
 | 
			
		||||
    private async Task LoadOwnerChannels()
 | 
			
		||||
    {
 | 
			
		||||
        var channels = await Task.WhenAll(_creds.OwnerIds.Select(id =>
 | 
			
		||||
        var channels = await _creds.OwnerIds.Select(id =>
 | 
			
		||||
        {
 | 
			
		||||
            var user = _client.GetUser(id);
 | 
			
		||||
            if (user is null)
 | 
			
		||||
                return Task.FromResult<IDMChannel>(null);
 | 
			
		||||
 | 
			
		||||
            return user.CreateDMChannelAsync();
 | 
			
		||||
        }));
 | 
			
		||||
        }).WhenAll();
 | 
			
		||||
 | 
			
		||||
        ownerChannels = channels.Where(x => x is not null)
 | 
			
		||||
                                .ToDictionary(x => x.Recipient.Id, x => x)
 | 
			
		||||
 
 | 
			
		||||
@@ -88,8 +88,6 @@ public static class EnumerableExtensions
 | 
			
		||||
        where T : class, IIndexed
 | 
			
		||||
        => new(enumerable);
 | 
			
		||||
 | 
			
		||||
    // todo use this extension instead of Task.WhenAll
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    ///     Creates a task that will complete when all of the <see cref="Task{TResult}" /> objects in an enumerable
 | 
			
		||||
    ///     collection have completed
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user