@@ -14,47 +14,58 @@ public static partial class RestClientExtensions
14
14
{
15
15
// TODO: AuditLogActionType overload?
16
16
public static IPagedEnumerable < IAuditLog > EnumerateAuditLogs ( this IRestClient client ,
17
- Snowflake guildId , int limit , Snowflake ? actorId = null , Snowflake ? startFromId = null ,
17
+ Snowflake guildId , int limit , Snowflake ? actorId = null ,
18
+ FetchDirection direction = FetchDirection . Before , Snowflake ? startFromId = null ,
18
19
IRestRequestOptions ? options = null )
19
- => client . EnumerateAuditLogs < IAuditLog > ( guildId , limit , actorId , startFromId , options ) ;
20
+ {
21
+ return client . EnumerateAuditLogs < IAuditLog > ( guildId , limit , actorId , direction , startFromId , options ) ;
22
+ }
20
23
21
24
public static IPagedEnumerable < TAuditLog > EnumerateAuditLogs < TAuditLog > ( this IRestClient client ,
22
- Snowflake guildId , int limit , Snowflake ? actorId = null , Snowflake ? startFromId = null ,
25
+ Snowflake guildId , int limit , Snowflake ? actorId = null ,
26
+ FetchDirection direction = FetchDirection . Before , Snowflake ? startFromId = null ,
23
27
IRestRequestOptions ? options = null )
24
28
where TAuditLog : class , IAuditLog
25
- => PagedEnumerable . Create ( static ( state , cancellationToken ) =>
29
+ {
30
+ return PagedEnumerable . Create ( static ( state , cancellationToken ) =>
26
31
{
27
- var ( client , guildId , limit , actorId , startFromId , options ) = state ;
28
- return new FetchAuditLogsPagedEnumerator < TAuditLog > ( client , guildId , limit , actorId , startFromId , options , cancellationToken ) ;
29
- } , ( client , guildId , limit , actorId , startFromId , options ) ) ;
32
+ var ( client , guildId , limit , actorId , direction , startFromId , options ) = state ;
33
+ return new FetchAuditLogsPagedEnumerator < TAuditLog > ( client , guildId , limit , actorId , direction , startFromId , options , cancellationToken ) ;
34
+ } , ( client , guildId , limit , actorId , direction , startFromId , options ) ) ;
35
+ }
30
36
31
37
public static Task < IReadOnlyList < IAuditLog > > FetchAuditLogsAsync ( this IRestClient client ,
32
- Snowflake guildId , int limit = Discord . Limits . Rest . FetchAuditLogsPageSize , Snowflake ? actorId = null , Snowflake ? startFromId = null ,
38
+ Snowflake guildId , int limit = Discord . Limits . Rest . FetchAuditLogsPageSize , Snowflake ? actorId = null ,
39
+ FetchDirection direction = FetchDirection . Before , Snowflake ? startFromId = null ,
33
40
IRestRequestOptions ? options = null , CancellationToken cancellationToken = default )
34
- => client . FetchAuditLogsAsync < IAuditLog > ( guildId , limit , actorId , startFromId , options , cancellationToken ) ;
41
+ {
42
+ return client . FetchAuditLogsAsync < IAuditLog > ( guildId , limit , actorId , direction , startFromId , options , cancellationToken ) ;
43
+ }
35
44
36
45
public static Task < IReadOnlyList < TAuditLog > > FetchAuditLogsAsync < TAuditLog > ( this IRestClient client ,
37
- Snowflake guildId , int limit = Discord . Limits . Rest . FetchAuditLogsPageSize , Snowflake ? actorId = null , Snowflake ? startFromId = null ,
46
+ Snowflake guildId , int limit = Discord . Limits . Rest . FetchAuditLogsPageSize , Snowflake ? actorId = null ,
47
+ FetchDirection direction = FetchDirection . Before , Snowflake ? startFromId = null ,
38
48
IRestRequestOptions ? options = null , CancellationToken cancellationToken = default )
39
49
where TAuditLog : class , IAuditLog
40
50
{
41
51
if ( limit == 0 )
42
52
return Task . FromResult ( ReadOnlyList < TAuditLog > . Empty ) ;
43
53
44
- if ( limit <= 100 )
45
- return client . InternalFetchAuditLogsAsync < TAuditLog > ( guildId , limit , actorId , startFromId , options , cancellationToken ) ;
54
+ if ( limit <= Discord . Limits . Rest . FetchAuditLogsPageSize )
55
+ return client . InternalFetchAuditLogsAsync < TAuditLog > ( guildId , limit , actorId , direction , startFromId , options , cancellationToken ) ;
46
56
47
- var enumerable = client . EnumerateAuditLogs < TAuditLog > ( guildId , limit , actorId , startFromId , options ) ;
57
+ var enumerable = client . EnumerateAuditLogs < TAuditLog > ( guildId , limit , actorId , direction , startFromId , options ) ;
48
58
return enumerable . FlattenAsync ( cancellationToken ) ;
49
59
}
50
60
51
61
internal static async Task < IReadOnlyList < TAuditLog > > InternalFetchAuditLogsAsync < TAuditLog > ( this IRestClient client ,
52
- Snowflake guildId , int limit , Snowflake ? actorId , Snowflake ? startFromId ,
62
+ Snowflake guildId , int limit , Snowflake ? actorId ,
63
+ FetchDirection direction , Snowflake ? startFromId ,
53
64
IRestRequestOptions ? options , CancellationToken cancellationToken )
54
65
where TAuditLog : IAuditLog
55
66
{
56
67
var type = GetAuditLogActionType ( typeof ( TAuditLog ) ) ;
57
- var model = await client . ApiClient . FetchAuditLogsAsync ( guildId , limit , actorId , type , startFromId , options , cancellationToken ) . ConfigureAwait ( false ) ;
68
+ var model = await client . ApiClient . FetchAuditLogsAsync ( guildId , limit , actorId , type , direction , startFromId , options , cancellationToken ) . ConfigureAwait ( false ) ;
58
69
var list = new List < TAuditLog > ( ) ;
59
70
foreach ( var entry in model . AuditLogEntries )
60
71
{
0 commit comments