-
-
Notifications
You must be signed in to change notification settings - Fork 737
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Feature] Initial user apps support (#2883)
* omg it kinda works somehow * more things added * a bit of xmldocs * added interaction framework support * working? IF * more builder stuff * space * rename attribute to prevent conflict with `ContextType` enum * context type * moar features * remove integration types * trigger workflow * modelzzzz * `InteractionContextType` * allow setting custom status with `SetGameAsync` * bugzzz * app permissions * message interaction context * hm * push for cd * structs lets goooo * whoops forgot to change types * whoops x2 * tweak some things * xmldocs + missing prop + fix enabled in dm * moar validations * deprecate a bunch of stuffz * disable moar obsolete warnings * add IF sample * Apply suggestions from code review Co-authored-by: Quin Lynch <49576606+quinchs@users.noreply.github.com> * Update src/Discord.Net.Rest/Entities/RestApplication.cs Co-authored-by: Quin Lynch <49576606+quinchs@users.noreply.github.com> --------- Co-authored-by: Quin Lynch <49576606+quinchs@users.noreply.github.com>
- Loading branch information
Showing
63 changed files
with
1,234 additions
and
277 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
|
||
// This parameteres can be configured on the module level | ||
// Set supported command context types to Bot DMs and Private Channels (regular DM & GDM) | ||
[CommandContextType(InteractionContextType.BotDm, InteractionContextType.PrivateChannel)] | ||
// Set supported integration installation type to User Install | ||
[IntegrationType(ApplicationIntegrationType.UserInstall)] | ||
public class CommandModule() : InteractionModuleBase<SocketInteractionContext> | ||
{ | ||
[SlashCommand("test", "Just a test command")] | ||
public async Task TestCommand() | ||
=> await RespondAsync("Hello There"); | ||
|
||
// But can also be overridden on the command level | ||
[CommandContextType(InteractionContextType.BotDm, InteractionContextType.PrivateChannel, InteractionContextType.Guild)] | ||
[IntegrationType(ApplicationIntegrationType.GuildInstall)] | ||
[SlashCommand("echo", "Echo the input")] | ||
public async Task EchoCommand(string input) | ||
=> await RespondAsync($"You said: {input}"); | ||
} |
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
17 changes: 17 additions & 0 deletions
17
src/Discord.Net.Core/Entities/Applications/ApplicationIntegrationType.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,17 @@ | ||
namespace Discord; | ||
|
||
/// <summary> | ||
/// Defines where an application can be installed. | ||
/// </summary> | ||
public enum ApplicationIntegrationType | ||
{ | ||
/// <summary> | ||
/// The application can be installed to a guild. | ||
/// </summary> | ||
GuildInstall = 0, | ||
|
||
/// <summary> | ||
/// The application can be installed to a user. | ||
/// </summary> | ||
UserInstall = 1, | ||
} |
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
File renamed without changes.
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
22 changes: 22 additions & 0 deletions
22
src/Discord.Net.Core/Entities/Interactions/ApplicationCommands/InteractionContextType.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,22 @@ | ||
namespace Discord; | ||
|
||
/// <summary> | ||
/// Represents a context in Discord where an interaction can be used. | ||
/// </summary> | ||
public enum InteractionContextType | ||
{ | ||
/// <summary> | ||
/// The command can be used in guilds. | ||
/// </summary> | ||
Guild = 0, | ||
|
||
/// <summary> | ||
/// The command can be used in DM channel with the bot. | ||
/// </summary> | ||
BotDm = 1, | ||
|
||
/// <summary> | ||
/// The command can be used in private channels. | ||
/// </summary> | ||
PrivateChannel = 2 | ||
} |
File renamed without changes.
File renamed without changes.
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
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.