-
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.
Implement interfaces of new REST API endpoints.
- Loading branch information
Showing
3 changed files
with
355 additions
and
0 deletions.
There are no files selected for viewing
183 changes: 183 additions & 0 deletions
183
Backend/Remora.Discord.API.Abstractions/API/Rest/IDiscordRestApplicationAPI.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,183 @@ | ||
// | ||
// IDiscordRestApplicationAPI.cs | ||
// | ||
// Author: | ||
// Jarl Gullberg <[email protected]> | ||
// | ||
// Copyright (c) 2017 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 System.Threading; | ||
using System.Threading.Tasks; | ||
using JetBrains.Annotations; | ||
using Remora.Discord.API.Abstractions.Objects; | ||
using Remora.Discord.API.Abstractions.Results; | ||
using Remora.Discord.Core; | ||
|
||
namespace Remora.Discord.API.Abstractions.Rest | ||
{ | ||
/// <summary> | ||
/// Represents the Discord application API. | ||
/// </summary> | ||
[PublicAPI] | ||
public interface IDiscordRestApplicationAPI | ||
{ | ||
/// <summary> | ||
/// Gets the global commands for the application. | ||
/// </summary> | ||
/// <param name="applicationID">The ID of the bot application.</param> | ||
/// <param name="ct">The cancellation token for this operation.</param> | ||
/// <returns>A retrieval result which may or may not have succeeded.</returns> | ||
Task<IRetrieveRestEntityResult<IReadOnlyList<IApplicationCommand>>> GetGlobalApplicationCommandsAsync | ||
( | ||
Snowflake applicationID, | ||
CancellationToken ct | ||
); | ||
|
||
/// <summary> | ||
/// Creates a new global command. | ||
/// </summary> | ||
/// <remarks> | ||
/// Creating a new command with the same name as an existing command will overwrite the old command. | ||
/// </remarks> | ||
/// <param name="applicationID">The ID of the bot application.</param> | ||
/// <param name="name">The name of the command. 3-32 characters.</param> | ||
/// <param name="description">The description of the command. 1-100 characters.</param> | ||
/// <param name="options">The parameters for the command.</param> | ||
/// <param name="ct">The cancellation token for this operation.</param> | ||
/// <returns>A creation result which may or may not have succeeded.</returns> | ||
Task<ICreateRestEntityResult<IApplicationCommand>> CreateGlobalApplicationCommandAsync | ||
( | ||
Snowflake applicationID, | ||
string name, | ||
string description, | ||
Optional<IReadOnlyList<IApplicationCommandOption>> options, | ||
CancellationToken ct | ||
); | ||
|
||
/// <summary> | ||
/// TODO: Check if name/description are actually optional. Docs say they aren't. | ||
/// Edits a new global command. | ||
/// </summary> | ||
/// <param name="applicationID">The ID of the bot application.</param> | ||
/// <param name="commandID">The ID of the command.</param> | ||
/// <param name="name">The name of the command. 3-32 characters.</param> | ||
/// <param name="description">The description of the command. 1-100 characters.</param> | ||
/// <param name="options">The parameters for the command.</param> | ||
/// <param name="ct">The cancellation token for this operation.</param> | ||
/// <returns>A creation result which may or may not have succeeded.</returns> | ||
Task<IModifyRestEntityResult<IApplicationCommand>> EditGlobalApplicationCommandAsync | ||
( | ||
Snowflake applicationID, | ||
Snowflake commandID, | ||
Optional<string> name, | ||
Optional<string> description, | ||
Optional<IReadOnlyList<IApplicationCommandOption>> options, | ||
CancellationToken ct | ||
); | ||
|
||
/// <summary> | ||
/// Deletes the given global command. | ||
/// </summary> | ||
/// <param name="applicationID">The ID of the bot application.</param> | ||
/// <param name="commandID">The ID of the command.</param> | ||
/// <param name="ct">The cancellation token for this operation.</param> | ||
/// <returns>A deletion result which may or may not have succeeded.</returns> | ||
Task<IDeleteRestEntityResult> DeleteGlobalApplicationCommandAsync | ||
( | ||
Snowflake applicationID, | ||
Snowflake commandID, | ||
CancellationToken ct | ||
); | ||
|
||
/// <summary> | ||
/// Gets the guild commands for the application. | ||
/// </summary> | ||
/// <param name="applicationID">The ID of the bot application.</param> | ||
/// <param name="guildID">The ID of the guild.</param> | ||
/// <param name="ct">The cancellation token for this operation.</param> | ||
/// <returns>A retrieval result which may or may not have succeeded.</returns> | ||
Task<IRetrieveRestEntityResult<IReadOnlyList<IApplicationCommand>>> GetGuildApplicationCommandsAsync | ||
( | ||
Snowflake applicationID, | ||
Snowflake guildID, | ||
CancellationToken ct | ||
); | ||
|
||
/// <summary> | ||
/// Creates a new guild command. | ||
/// </summary> | ||
/// <remarks> | ||
/// Creating a new command with the same name as an existing command will overwrite the old command. | ||
/// </remarks> | ||
/// <param name="applicationID">The ID of the bot application.</param> | ||
/// <param name="guildID">The ID of the guild.</param> | ||
/// <param name="name">The name of the command. 3-32 characters.</param> | ||
/// <param name="description">The description of the command. 1-100 characters.</param> | ||
/// <param name="options">The parameters for the command.</param> | ||
/// <param name="ct">The cancellation token for this operation.</param> | ||
/// <returns>A creation result which may or may not have succeeded.</returns> | ||
Task<ICreateRestEntityResult<IApplicationCommand>> CreateGuildApplicationCommandAsync | ||
( | ||
Snowflake applicationID, | ||
Snowflake guildID, | ||
string name, | ||
string description, | ||
Optional<IReadOnlyList<IApplicationCommandOption>> options, | ||
CancellationToken ct | ||
); | ||
|
||
/// <summary> | ||
/// TODO: Check if name/description are actually optional. Docs say they aren't. | ||
/// Edits a new guild command. | ||
/// </summary> | ||
/// <param name="applicationID">The ID of the bot application.</param> | ||
/// <param name="guildID">The ID of the guild.</param> | ||
/// <param name="commandID">The ID of the command.</param> | ||
/// <param name="name">The name of the command. 3-32 characters.</param> | ||
/// <param name="description">The description of the command. 1-100 characters.</param> | ||
/// <param name="options">The parameters for the command.</param> | ||
/// <param name="ct">The cancellation token for this operation.</param> | ||
/// <returns>A creation result which may or may not have succeeded.</returns> | ||
Task<IModifyRestEntityResult<IApplicationCommand>> EditGuildApplicationCommandAsync | ||
( | ||
Snowflake applicationID, | ||
Snowflake guildID, | ||
Snowflake commandID, | ||
Optional<string> name, | ||
Optional<string> description, | ||
Optional<IReadOnlyList<IApplicationCommandOption>> options, | ||
CancellationToken ct | ||
); | ||
|
||
/// <summary> | ||
/// Deletes the given guild command. | ||
/// </summary> | ||
/// <param name="applicationID">The ID of the bot application.</param> | ||
/// <param name="guildID">The ID of the guild.</param> | ||
/// <param name="commandID">The ID of the command.</param> | ||
/// <param name="ct">The cancellation token for this operation.</param> | ||
/// <returns>A deletion result which may or may not have succeeded.</returns> | ||
Task<IDeleteRestEntityResult> DeleteGuildApplicationCommandAsync | ||
( | ||
Snowflake applicationID, | ||
Snowflake guildID, | ||
Snowflake commandID, | ||
CancellationToken ct | ||
); | ||
} | ||
} |
55 changes: 55 additions & 0 deletions
55
Backend/Remora.Discord.API.Abstractions/API/Rest/IDiscordRestInteractionAPI.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,55 @@ | ||
// | ||
// IDiscordRestInteractionAPI.cs | ||
// | ||
// Author: | ||
// Jarl Gullberg <[email protected]> | ||
// | ||
// Copyright (c) 2017 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.Threading; | ||
using System.Threading.Tasks; | ||
using JetBrains.Annotations; | ||
using Remora.Discord.API.Abstractions.Objects; | ||
using Remora.Discord.API.Abstractions.Results; | ||
using Remora.Discord.Core; | ||
|
||
namespace Remora.Discord.API.Abstractions.Rest | ||
{ | ||
/// <summary> | ||
/// Represents the Discord interaction API. | ||
/// </summary> | ||
[PublicAPI] | ||
public interface IDiscordRestInteractionAPI | ||
{ | ||
/// <summary> | ||
/// TODO: Check if we actually get an IInteractionResponse back from this. | ||
/// Creates a response to an interaction from the gateway. | ||
/// </summary> | ||
/// <param name="interactionID">The ID of the interaction.</param> | ||
/// <param name="interactionToken">The interaction token.</param> | ||
/// <param name="response">The response.</param> | ||
/// <param name="ct">The cancellation token for this operation.</param> | ||
/// <returns>A creation result which may or may not have succeeded.</returns> | ||
Task<ICreateRestEntityResult<IInteractionResponse>> CreateInteractionResponseAsync | ||
( | ||
Snowflake interactionID, | ||
string interactionToken, | ||
IInteractionResponse response, | ||
CancellationToken ct | ||
); | ||
} | ||
} |
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