diff --git a/DisCatSharp.ApplicationCommands/Context/ApplicationCommandsPermissionContext.cs b/DisCatSharp.ApplicationCommands/Context/ApplicationCommandsPermissionContext.cs deleted file mode 100644 index a9cb30110..000000000 --- a/DisCatSharp.ApplicationCommands/Context/ApplicationCommandsPermissionContext.cs +++ /dev/null @@ -1,75 +0,0 @@ -// This file is part of the DisCatSharp project, a fork of DSharpPlus. -// -// Copyright (c) 2021 AITSYS -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. - -using System; -using System.Collections.Generic; -using DisCatSharp.Entities; - -namespace DisCatSharp.ApplicationCommands -{ - /// - /// The application commands permission context. - /// - public class ApplicationCommandsPermissionContext - { - /// - /// Gets the type. - /// - public Type Type { get; } - - /// - /// Gets the name. - /// - public string Name { get; } - - /// - /// Gets the permissions. - /// - public IReadOnlyCollection Permissions => _permissions; - private readonly List _permissions = new(); - - /// - /// Initializes a new instance of the class. - /// - /// The type. - /// The name. - internal ApplicationCommandsPermissionContext(Type type, string name) - { - this.Type = type; - this.Name = name; - } - - /// - /// Adds a user to the permission system. - /// - /// The Id of the user to give this permission. - /// The permission for the application command. If set to true, they can use the command. If set to false, they can't use the command. - public void AddUser(ulong userId, bool permission) => _permissions.Add(new DiscordApplicationCommandPermission(userId, ApplicationCommandPermissionType.User, permission)); - - /// - /// Adds a user to the permission system. - /// - /// The Id of the role to give this permission. - /// The permission for the application command. If set to true, they can use the command. If set to false, they can't use the command. - public void AddRole(ulong roleId, bool permission) => _permissions.Add(new DiscordApplicationCommandPermission(roleId, ApplicationCommandPermissionType.Role, permission)); - } -} diff --git a/DisCatSharp.ApplicationCommands/Context/AutocompleteContext.cs b/DisCatSharp.ApplicationCommands/Context/AutocompleteContext.cs deleted file mode 100644 index 13457508b..000000000 --- a/DisCatSharp.ApplicationCommands/Context/AutocompleteContext.cs +++ /dev/null @@ -1,48 +0,0 @@ -// This file is part of the DisCatSharp project, a fork of DSharpPlus. -// -// Copyright (c) 2021 AITSYS -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. - -using System.Collections.Generic; -using DisCatSharp.Entities; - -namespace DisCatSharp.ApplicationCommands -{ - /// - /// Represents a context for an autocomplete interaction. - /// - public class AutocompleteContext - { - /// - /// The interaction created. - /// - public DiscordInteraction Interaction { get; internal set; } - - /// - /// The options already provided. - /// - public IReadOnlyList Options { get; internal set; } - - /// - /// The option to autocomplete. - /// - public DiscordInteractionDataOption FocusedOption { get; internal set; } - } -} diff --git a/DisCatSharp.ApplicationCommands/Context/BaseContext.cs b/DisCatSharp.ApplicationCommands/Context/BaseContext.cs deleted file mode 100644 index 75363284a..000000000 --- a/DisCatSharp.ApplicationCommands/Context/BaseContext.cs +++ /dev/null @@ -1,163 +0,0 @@ -// This file is part of the DisCatSharp project. -// -// Copyright (c) 2021 AITSYS -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. - -using System; -using System.Threading.Tasks; -using DisCatSharp.Entities; -using DisCatSharp.Enums; -using Microsoft.Extensions.DependencyInjection; - -namespace DisCatSharp.ApplicationCommands -{ - /// - /// Respresents a base context for application command contexts. - /// - public class BaseContext - { - /// - /// Gets the interaction that was created. - /// - public DiscordInteraction Interaction { get; internal set; } - - /// - /// Gets the client for this interaction. - /// - public DiscordClient Client { get; internal set; } - - /// - /// Gets the guild this interaction was executed in. - /// - public DiscordGuild Guild { get; internal set; } - - /// - /// Gets the channel this interaction was executed in. - /// - public DiscordChannel Channel { get; internal set; } - - /// - /// Gets the user which executed this interaction. - /// - public DiscordUser User { get; internal set; } - - /// - /// Gets the member which executed this interaction, or null if the command is in a DM. - /// - public DiscordMember Member - => this.User is DiscordMember member ? member : null; - - /// - /// Gets the application command module this interaction was created in. - /// - public ApplicationCommandsExtension ApplicationCommandsExtension { get; internal set; } - - /// - /// Gets the token for this interaction. - /// - public string Token { get; internal set; } - - /// - /// Gets the id for this interaction. - /// - public ulong InteractionId { get; internal set; } - - /// - /// Gets the name of the command. - /// - public string CommandName { get; internal set; } - - /// - /// Gets the type of this interaction. - /// - public ApplicationCommandType Type { get; internal set;} - - /// - /// Gets the service provider. - /// This allows passing data around without resorting to static members. - /// Defaults to null. - /// - public IServiceProvider Services { get; internal set; } = new ServiceCollection().BuildServiceProvider(true); - - /// - /// Creates a response to this interaction. - /// You must create a response within 3 seconds of this interaction being executed; if the command has the potential to take more than 3 seconds, create a at the start, and edit the response later. - /// - /// The type of the response. - /// The data to be sent, if any. - /// - public Task CreateResponseAsync(InteractionResponseType type, DiscordInteractionResponseBuilder builder = null) - => this.Interaction.CreateResponseAsync(type, builder); - - /// - /// Edits the interaction response. - /// - /// The data to edit the response with. - /// - public Task EditResponseAsync(DiscordWebhookBuilder builder) - => this.Interaction.EditOriginalResponseAsync(builder); - - /// - /// Deletes the interaction response. - /// - /// - public Task DeleteResponseAsync() - => this.Interaction.DeleteOriginalResponseAsync(); - - /// - /// Creates a follow up message to the interaction. - /// - /// The message to be sent, in the form of a webhook. - /// The created message. - public Task FollowUpAsync(DiscordFollowupMessageBuilder builder) - => this.Interaction.CreateFollowupMessageAsync(builder); - - /// - /// Edits a followup message. - /// - /// The id of the followup message to edit. - /// The webhook builder. - /// - public Task EditFollowupAsync(ulong followupMessageId, DiscordWebhookBuilder builder) - => this.Interaction.EditFollowupMessageAsync(followupMessageId, builder); - - /// - /// Deletes a followup message. - /// - /// The id of the followup message to delete. - /// - public Task DeleteFollowupAsync(ulong followupMessageId) - => this.Interaction.DeleteFollowupMessageAsync(followupMessageId); - - /// - /// Gets the followup message. - /// - /// The followup message id. - public Task GetFollowupMessageAsync(ulong followupMessageId) - => this.Interaction.GetFollowupMessageAsync(followupMessageId); - - /// - /// Gets the original interaction response. - /// - /// The original interaction response. - public Task GetOriginalResponseAsync() - => this.Interaction.GetOriginalResponseAsync(); - } -} diff --git a/DisCatSharp.ApplicationCommands/Context/ContextMenuContext.cs b/DisCatSharp.ApplicationCommands/Context/ContextMenuContext.cs deleted file mode 100644 index 76834a995..000000000 --- a/DisCatSharp.ApplicationCommands/Context/ContextMenuContext.cs +++ /dev/null @@ -1,48 +0,0 @@ -// This file is part of the DisCatSharp project. -// -// Copyright (c) 2021 AITSYS -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. - -using DisCatSharp.Entities; - -namespace DisCatSharp.ApplicationCommands -{ - /// - /// Respresents a context for a context menu. - /// - public sealed class ContextMenuContext : BaseContext - { - /// - /// The user this command targets, if applicable. - /// - public DiscordUser TargetUser { get; internal set; } - - /// - /// The member this command targets, if applicable. - /// - public DiscordMember TargetMember - => this.TargetUser is DiscordMember member ? member : null; - - /// - /// The message this command targets, if applicable. - /// - public DiscordMessage TargetMessage { get; internal set; } - } -} diff --git a/DisCatSharp.ApplicationCommands/Context/InteractionContext.cs b/DisCatSharp.ApplicationCommands/Context/InteractionContext.cs deleted file mode 100644 index 58b7a28b0..000000000 --- a/DisCatSharp.ApplicationCommands/Context/InteractionContext.cs +++ /dev/null @@ -1,51 +0,0 @@ -// This file is part of the DisCatSharp project. -// -// Copyright (c) 2021 AITSYS -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. - -using System; -using System.Collections.Generic; -using System.Threading.Tasks; -using DisCatSharp.Entities; -using Microsoft.Extensions.DependencyInjection; - -namespace DisCatSharp.ApplicationCommands -{ - /// - /// Represents a context for an interaction. - /// - public sealed class InteractionContext : BaseContext - { - /// - /// Gets the users mentioned in the command parameters. - /// - public IReadOnlyList ResolvedUserMentions { get; internal set; } - - /// - /// Gets the roles mentioned in the command parameters. - /// - public IReadOnlyList ResolvedRoleMentions { get; internal set; } - - /// - /// Gets the channels mentioned in the command parameters. - /// - public IReadOnlyList ResolvedChannelMentions { get; internal set; } - } -}