diff --git a/DisCatSharp.ApplicationCommands/Context/ApplicationCommandsPermissionContext.cs b/DisCatSharp.ApplicationCommands/Context/ApplicationCommandsPermissionContext.cs
index a9cb30110..14ee2c6f4 100644
--- a/DisCatSharp.ApplicationCommands/Context/ApplicationCommandsPermissionContext.cs
+++ b/DisCatSharp.ApplicationCommands/Context/ApplicationCommandsPermissionContext.cs
@@ -1,75 +1,82 @@
// 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));
+
+ ///
+ /// 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 AddChannel(ulong channelId, bool permission) => _permissions.Add(new DiscordApplicationCommandPermission(channelId, ApplicationCommandPermissionType.Channel, permission));
}
}
diff --git a/DisCatSharp/Enums/Application/ApplicationCommandPermissionType.cs b/DisCatSharp/Enums/Application/ApplicationCommandPermissionType.cs
index 40964b7df..8712f5c61 100644
--- a/DisCatSharp/Enums/Application/ApplicationCommandPermissionType.cs
+++ b/DisCatSharp/Enums/Application/ApplicationCommandPermissionType.cs
@@ -1,42 +1,47 @@
// 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;
namespace DisCatSharp
{ ///
/// Represents the type of the application command permission.
///
[Flags]
public enum ApplicationCommandPermissionType
{
///
/// The permission is bound to a role.
///
Role = 1,
///
/// The permission is bound to a user.
///
- User = 2
+ User = 2,
+
+ ///
+ /// The permission is bound to a channel.
+ ///
+ Channel = 3
}
}