-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #345 from VelvetToroyashi/velvet/feat/webhook-events
Add support for incoming webhook commands
- Loading branch information
Showing
18 changed files
with
514 additions
and
1 deletion.
There are no files selected for viewing
54 changes: 54 additions & 0 deletions
54
....Discord.API.Abstractions/API/Objects/WebhookEvents/IApplicationAuthorizedWebhookEvent.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
// | ||
// IApplicationAuthorizedWebhookEvent.cs | ||
// | ||
// Author: | ||
// Jarl Gullberg <[email protected]> | ||
// | ||
// Copyright (c) Jarl Gullberg | ||
// | ||
// This program is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU Lesser General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// This program is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU Lesser General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU Lesser General Public License | ||
// along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
// | ||
|
||
using System.Collections.Generic; | ||
using JetBrains.Annotations; | ||
using Remora.Rest.Core; | ||
|
||
namespace Remora.Discord.API.Abstractions.Objects; | ||
|
||
/// <summary> | ||
/// Represents a webhook event for when an application is authorized. | ||
/// </summary> | ||
[PublicAPI] | ||
public interface IApplicationAuthorizedWebhookEvent | ||
{ | ||
/// <summary> | ||
/// Gets the user that authorized the application. | ||
/// </summary> | ||
IUser User { get; } | ||
|
||
/// <summary> | ||
/// Gets the scopes that the application was authorized for. | ||
/// </summary> | ||
IReadOnlyList<string> Scopes { get; } | ||
|
||
/// <summary> | ||
/// Gets the guild that the application was authorized for, if <see cref="IntegrationType"/> is <see cref="ApplicationIntegrationType.GuildInstallable"/>. | ||
/// </summary> | ||
Optional<IPartialGuild> Guild { get; } | ||
|
||
/// <summary> | ||
/// Gets the integration type of the application. | ||
/// </summary> | ||
Optional<ApplicationIntegrationType> IntegrationType { get; } | ||
} |
49 changes: 49 additions & 0 deletions
49
Backend/Remora.Discord.API.Abstractions/API/Objects/WebhookEvents/IWebhookEvent.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// | ||
// IWebhookEvent.cs | ||
// | ||
// Author: | ||
// Jarl Gullberg <[email protected]> | ||
// | ||
// Copyright (c) Jarl Gullberg | ||
// | ||
// This program is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU Lesser General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// This program is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU Lesser General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU Lesser General Public License | ||
// along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
// | ||
|
||
using System; | ||
using JetBrains.Annotations; | ||
using OneOf; | ||
|
||
namespace Remora.Discord.API.Abstractions.Objects; | ||
|
||
/// <summary> | ||
/// Represents a webhook event. | ||
/// </summary> | ||
[PublicAPI] | ||
public interface IWebhookEvent | ||
{ | ||
/// <summary> | ||
/// Gets the type of the event. | ||
/// </summary> | ||
WebhookEventType Type { get; } | ||
|
||
/// <summary> | ||
/// Gets the timestamp of the event. | ||
/// </summary> | ||
DateTimeOffset Timestamp { get; } | ||
|
||
/// <summary> | ||
/// Gets the data of the event. | ||
/// </summary> | ||
OneOf<IApplicationAuthorizedWebhookEvent, IEntitlement> Data { get; } | ||
} |
48 changes: 48 additions & 0 deletions
48
Backend/Remora.Discord.API.Abstractions/API/Objects/WebhookEvents/IWebhookEventPayload.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
// | ||
// IWebhookEventPayload.cs | ||
// | ||
// Author: | ||
// Jarl Gullberg <[email protected]> | ||
// | ||
// Copyright (c) Jarl Gullberg | ||
// | ||
// This program is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU Lesser General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// This program is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU Lesser General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU Lesser General Public License | ||
// along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
// | ||
|
||
using JetBrains.Annotations; | ||
using Remora.Rest.Core; | ||
|
||
namespace Remora.Discord.API.Abstractions.Objects; | ||
|
||
/// <summary> | ||
/// Represents a payload for a webhook event. | ||
/// </summary> | ||
[PublicAPI] | ||
public interface IWebhookEventPayload | ||
{ | ||
/// <summary> | ||
/// Gets the version of this payload. Currently, always 1. | ||
/// </summary> | ||
int Version { get; } | ||
|
||
/// <summary> | ||
/// Gets the ID of the application. | ||
/// </summary> | ||
Snowflake ApplicationID { get; } | ||
|
||
/// <summary> | ||
/// Gets the type of the payload. | ||
/// </summary> | ||
WebhookEventPayloadType Type { get; } | ||
} |
39 changes: 39 additions & 0 deletions
39
Backend/Remora.Discord.API.Abstractions/API/Objects/WebhookEvents/WebhookEventPayloadType.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// | ||
// WebhookEventPayloadType.cs | ||
// | ||
// Author: | ||
// Jarl Gullberg <[email protected]> | ||
// | ||
// Copyright (c) Jarl Gullberg | ||
// | ||
// This program is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU Lesser General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// This program is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU Lesser General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU Lesser General Public License | ||
// along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
// | ||
|
||
namespace Remora.Discord.API.Abstractions.Objects; | ||
|
||
/// <summary> | ||
/// Represents the type of webhook event payload. | ||
/// </summary> | ||
public enum WebhookEventPayloadType | ||
{ | ||
/// <summary> | ||
/// The payload is a ping. | ||
/// </summary> | ||
Ping, | ||
|
||
/// <summary> | ||
/// The payload is an event with data. | ||
/// </summary> | ||
Event | ||
} |
44 changes: 44 additions & 0 deletions
44
Backend/Remora.Discord.API.Abstractions/API/Objects/WebhookEvents/WebhookEventType.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// | ||
// WebhookEventType.cs | ||
// | ||
// Author: | ||
// Jarl Gullberg <[email protected]> | ||
// | ||
// Copyright (c) Jarl Gullberg | ||
// | ||
// This program is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU Lesser General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// This program is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU Lesser General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU Lesser General Public License | ||
// along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
// | ||
|
||
namespace Remora.Discord.API.Abstractions.Objects; | ||
|
||
/// <summary> | ||
/// Represents the type of webhook event. | ||
/// </summary> | ||
public enum WebhookEventType | ||
{ | ||
/// <summary> | ||
/// The application was authorized to a user or guild. | ||
/// </summary> | ||
ApplicationAuthorized, | ||
|
||
/// <summary> | ||
/// An entitlement was created. | ||
/// </summary> | ||
EntitlementCreate, | ||
|
||
/// <summary> | ||
/// User was added to a Quest (currently unavailable). | ||
/// </summary> | ||
QuestUserEnrollment, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
Backend/Remora.Discord.API/API/Objects/WebhookEvents/ApplicationAuthorizedWebhookEvent.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// | ||
// ApplicationAuthorizedWebhookEvent.cs | ||
// | ||
// Author: | ||
// Jarl Gullberg <[email protected]> | ||
// | ||
// Copyright (c) Jarl Gullberg | ||
// | ||
// This program is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU Lesser General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// This program is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU Lesser General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU Lesser General Public License | ||
// along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
// | ||
|
||
using System.Collections.Generic; | ||
using JetBrains.Annotations; | ||
using Remora.Discord.API.Abstractions.Objects; | ||
using Remora.Rest.Core; | ||
|
||
namespace Remora.Discord.API.Objects; | ||
|
||
/// <inheritdoc cref="IApplicationAuthorizedWebhookEvent"/> | ||
[PublicAPI] | ||
public record ApplicationAuthorizedWebhookEvent | ||
( | ||
IUser User, | ||
IReadOnlyList<string> Scopes, | ||
Optional<IPartialGuild> Guild = default, | ||
Optional<ApplicationIntegrationType> IntegrationType = default | ||
) : IApplicationAuthorizedWebhookEvent; |
35 changes: 35 additions & 0 deletions
35
Backend/Remora.Discord.API/API/Objects/WebhookEvents/WebhookEvent.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// | ||
// WebhookEvent.cs | ||
// | ||
// Author: | ||
// Jarl Gullberg <[email protected]> | ||
// | ||
// Copyright (c) Jarl Gullberg | ||
// | ||
// This program is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU Lesser General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// This program is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU Lesser General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU Lesser General Public License | ||
// along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
// | ||
|
||
using System; | ||
using OneOf; | ||
using Remora.Discord.API.Abstractions.Objects; | ||
|
||
namespace Remora.Discord.API.Objects; | ||
|
||
/// <inheritdoc cref="IWebhookEvent"/> | ||
public record WebhookEvent | ||
( | ||
WebhookEventType Type, | ||
DateTimeOffset Timestamp, | ||
OneOf<IApplicationAuthorizedWebhookEvent, IEntitlement> Data | ||
) : IWebhookEvent; |
36 changes: 36 additions & 0 deletions
36
Backend/Remora.Discord.API/API/Objects/WebhookEvents/WebhookEventPayload.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// | ||
// WebhookEventPayload.cs | ||
// | ||
// Author: | ||
// Jarl Gullberg <[email protected]> | ||
// | ||
// Copyright (c) Jarl Gullberg | ||
// | ||
// This program is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU Lesser General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// This program is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU Lesser General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU Lesser General Public License | ||
// along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
// | ||
|
||
using JetBrains.Annotations; | ||
using Remora.Discord.API.Abstractions.Objects; | ||
using Remora.Rest.Core; | ||
|
||
namespace Remora.Discord.API.Objects; | ||
|
||
/// <inheritdoc cref="IWebhookEventPayload"/> | ||
[PublicAPI] | ||
public record WebhookEventPayload | ||
( | ||
int Version, | ||
Snowflake ApplicationID, | ||
WebhookEventPayloadType Type | ||
) : IWebhookEventPayload; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.