discord-net/Discord.Net

[Bug]: Remove the `reason` field from `AddBanAsync` and `KickAsync` methods or make them obsolete

1NieR opened this issue · 2 comments

1NieR commented

Check The Docs

  • I double checked the docs and couldn't find any useful information.

Verify Issue Source

  • I verified the issue was caused by Discord.Net.

Check your intents

  • I double checked that I have the required intents.

Description

Since API v10 the reason field has been removed and replaced by X-Audit-Log-Reason.
discord/discord-api-docs#5219 (comment)
API V10
ban
kick

Version

3.8.1

Working Version

No response

Logs

(none)

Sample

No response

Packages

N/A

How about instead we fix the field and not break many many bots

Just noting the locations in case someone wants to PR. I might get around to this myself eventually. Should be easy enough to change the reason logic to add the X-Audit-Log-Reason to the options parameter in both these methods (options.AuditLogReason = reason; perhaps?).

Possibly need to think of how to handle if both the reason param and RequestOptions.AuditLogReason are both supplied at the same time.

Ban:

string reason = string.IsNullOrWhiteSpace(args.Reason) ? "" : $"&reason={Uri.EscapeDataString(args.Reason)}";

Kick:
reason = string.IsNullOrWhiteSpace(reason) ? "" : $"?reason={Uri.EscapeDataString(reason)}";