Audit Logs implementation (#1055)

* Copy audit logs impl from old branch and clean up

I suck at using git, so I'm gonna use brute force.

* Remove unnecessary TODOs

Category channels do not provide any new information, and the other
I forgot to remove beforehand

* Add invite update data, clean up after feedback

* Remove TODOs, add WebhookType enum for future use

WebhookType is a future-use type, as currently audit logs are the only
thing which may return it.
This commit is contained in:
Finite Reality
2018-05-13 01:46:07 +01:00
committed by Christopher F
parent 97c893107b
commit 39dffe8585
48 changed files with 1576 additions and 3 deletions

View File

@@ -1206,6 +1206,26 @@ namespace Discord.API
return await SendAsync<IReadOnlyCollection<VoiceRegion>>("GET", () => $"guilds/{guildId}/regions", ids, options: options).ConfigureAwait(false);
}
//Audit logs
public async Task<AuditLog> GetAuditLogsAsync(ulong guildId, GetAuditLogsParams args, RequestOptions options = null)
{
Preconditions.NotEqual(guildId, 0, nameof(guildId));
Preconditions.NotNull(args, nameof(args));
options = RequestOptions.CreateOrClone(options);
int limit = args.Limit.GetValueOrDefault(int.MaxValue);
var ids = new BucketIds(guildId: guildId);
Expression<Func<string>> endpoint;
if (args.BeforeEntryId.IsSpecified)
endpoint = () => $"guilds/{guildId}/audit-logs?limit={limit}&before={args.BeforeEntryId.Value}";
else
endpoint = () => $"guilds/{guildId}/audit-logs?limit={limit}";
return await SendAsync<AuditLog>("GET", endpoint, ids, options: options).ConfigureAwait(false);
}
//Webhooks
public async Task<Webhook> CreateWebhookAsync(ulong channelId, CreateWebhookParams args, RequestOptions options = null)
{