Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to check two roles

Tags:

discord.js

I am trying to make command, that works if the author has admin or owner role. But I don't know how to check if user has "admin" OR "owner" role (multiple roles). And I am using discord.js v12.

My code:

client.on('message', message => {
    if (message.content.startsWith('!ban'))
if(message.member.roles.cache.find(r => r.name === "owner")) {
        message.delete();
    let member1 = message.mentions.members.first();
    if(!member1) return message.channel.send("You need to mention the @user!").then((declineMsg) => {
declineMsg.delete({timeout: 5000});})
      let banned = message.guild.roles.cache.find(role => role.name === "banned");
    member1.roles.add(banned);
 message.channel.send('Succesfully banned user!').then(message.delete({timeout: 5000}))}});
  });

client.on('message', message => {
    if (message.content.startsWith('!ban'))
if(message.member.roles.cache.find(r => r.name === "admin")) {
        message.delete();
    let member1 = message.mentions.members.first();
    if(!member1) return message.channel.send("You need to mention the @user!").then((declineMsg) => {
declineMsg.delete({timeout: 5000});})

      let banned = message.guild.roles.cache.find(role => role.name === "banned");
    member1.roles.add(banned);
    message.channel.send(`Succesfully banned user!`).then(message.delete({timeout: 5000}))}});
  });
like image 665
Latepate Avatar asked Oct 21 '21 05:10

Latepate


People also ask

How to Compare 2 roles in SAP?

Steps for Role Comparing: Click on Across systems option it will give option to select the sys name under Remote Comparison there enter the SYS ID between which system you want to do comparison and put the role name in compare role section then execute it will give you the result.

Can you explain what a user compare does in SAP security?

User Comparison will reconcile the PROFILES within a user's account and make the necessary changes. This is especially true when you've assigned specific Valid-To dates for the roles on an account. If the Valid-To (expiry) date of a role has passed, the User Comparison will REMOVE the profile/role from that account.

How do you do mass user comparison in SAP?

SAP Transaction Codes for Mass User Comparison — the most relevant and popular TCodes are listed at the top. You can click on TCodes to view more information like related TCodes, SAP Help/reference pages, etc. You can also click on the Functional Area to view all the TCodes for that module/sub-module.

How to check for user roles in Java?

The first way to check for user roles in Java is to use the @PreAuthorize annotation provided by Spring Security. This annotation can be applied to a class or method, and it accepts a single string value that represents a SpEL expression. Before we can use this annotation, we must first enable global method security.

How do I list all SQL Server roles for a user?

Listing SQL Server roles for a user. 1 Start Microsoft SQL Server Management Studio (MSSMS). 2 On the File menu, click Connect Object Explorer. 3 In the Connect to Server dialog box, specify the following settings:

How to compare roles in different systems?

For role comparison both the roles must be in the same system, in same client. Transaction code SUIM -> Comparison-> Roles If the roles are in different system, then transport the role into one of the system and do comparison. If no transport connection defined then, you can use the upload and download option in the PFCG.

Do you know the server and database roles for each user?

Each SQL database can also have its own unique permissions and roles. In order to maintain security and comply with many regulations, including PCI DSS and HIPAA, you need to know all the server and database roles assigned to each user. That’s a tough job if all you have are native tools because of all the complexity involved.


1 Answers

You need to use something like this:

let role1 = message.guild.roles.cache.find(r => r.name === "owner");
let role2 = message.guild.roles.cache.find(r => r.name === "admin");

if(!message.member.roles.cache.has(role1.id) && !message.member.roles.cache.has(role2.id)) return message.reply("User don't have required roles!")
like image 108
MegaMix_Craft Avatar answered Oct 27 '22 00:10

MegaMix_Craft