diff --git a/PluralKit.Bot/Commands/Api.cs b/PluralKit.Bot/Commands/Api.cs index 6c5a88a6..85d0634f 100644 --- a/PluralKit.Bot/Commands/Api.cs +++ b/PluralKit.Bot/Commands/Api.cs @@ -1,3 +1,4 @@ +using System.Text.RegularExpressions; using System.Threading.Tasks; using Myriad.Extensions; @@ -13,6 +14,7 @@ namespace PluralKit.Bot { private readonly ModelRepository _repo; private readonly DispatchService _dispatch; + private static readonly Regex _webhookRegex = new(@"https://(?:\\w+.)?discord(?:app)?.com/api(?:/v.*)?/webhooks/(.*)"); public Api(ModelRepository repo, DispatchService dispatch) { _repo = repo; @@ -121,6 +123,9 @@ namespace PluralKit.Bot if (!await DispatchExt.ValidateUri(newUrl)) throw new PKError($"The URL {newUrl.AsCode()} is invalid or I cannot access it. Are you sure this is a valid, publicly accessible URL?"); + if (_webhookRegex.IsMatch(newUrl)) + throw new PKError("PluralKit does not currently support setting a Discord webhook URL as your system's webhook URL."); + var newToken = StringUtils.GenerateToken(); await _repo.UpdateSystem(ctx.System.Id, new()