简体   繁体   English

如何禁用 D#+ 命令不向没有特定权限的用户显示?

[英]How do i disable a D#+ Command To not show for users who dont have certain permissions?

how do i disable a D#+ Command to not show for users who don't have specific permissions such as Administrator, Or Owner?如何禁用 D#+ 命令以不向没有特定权限(例如管理员或所有者)的用户显示?

a reply would be appreciated, thanks.答复将不胜感激,谢谢。

The easiest way to hide a command from someone who should not have access to it is with attribution.向不应访问命令的人隐藏命令的最简单方法是使用属性。

[SlashCommand("hello", "hello world")]
[RequirePermissions(DSharpPlus.Permissions.Administrator)] //Must have admin perm to see/use
public static async Task HelloWorld(InteractionContext ctx)
{
    await ctx.CreateResponseAsync(InteractionResponseType.ChannelMessageWithSource,
      new DiscordInteractionResponseBuilder().WithContent("Hello, World!"));
}

You can change the attribution to any of the permissions found in DSharpPlus.Permissions您可以将属性更改为在DSharpPlus.Permissions中找到的任何权限

You can also use roles for this as well:您也可以为此使用角色:

[SlashCommand("hello", "hello world")]
[RequireRoles(RoleCheckMode.Any, new ulong[] { 99999 })] // must have role with ID 99999
public static async Task HelloWorld(InteractionContext ctx)
{
    await ctx.CreateResponseAsync(InteractionResponseType.ChannelMessageWithSource,
      new DiscordInteractionResponseBuilder().WithContent("Hello, World!"));
}

RoleCheckMode can be used to define parameters for when you have multiple roles involved, and you can find more about this attribution here RoleCheckMode可用于在涉及多个角色时定义参数,您可以在此处找到有关此属性的更多信息

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何获取已登录的本地Windows用户列表? - How do I get a list of local Windows users who are logged in? 我正在尝试从未使用LINQ创建具有特定属性的其他对象的用户列表中创建新的用户列表 - I am trying create a new list of users from a list of users who have not created an additional object with a certain property using LINQ 我怎样才能有效地使用 switch case 只向达到购买年龄的孩子展示某些电影? - How can I effectively use a switch case to only show certain movies to children who are of age to purchase them? 如何确定我是否对数据库具有执行权限? - How do I determine if I have execute permissions on a DB programatically? 如何在列表框中为用户而不是程序禁用选择? C# - How do I disable selection in a listbox for users but not the program? c# 我如何获得用户(不是我的Facebook朋友)个人资料图片 - How do I get a users (who is not my facebook friend) profile pic 如何显示组中的所有用户-IBM Cognos 10 SDK - How to show all users who are in a group - IBM Cognos 10 SDK 如何禁用其他用户访问连接到数据库的C#中的特定表单? - How will I disable other users to access a certain form in c# connected to database? Identity Manager如何获取具有任何角色的所有用户 - Identity Manager How To Get All Users Who Have Any Role 如何通过UWP应用向用户显示状态? - How do I show status to users from my UWP app?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM