Add InteractionRole#getAsMention + InteractionRole#canInteract

This commit is contained in:
Josh Roy 2021-08-06 20:50:20 -04:00 committed by MD
parent ba5a8becfc
commit 52c500ee6d
2 changed files with 27 additions and 0 deletions

View File

@ -10,6 +10,12 @@ public interface InteractionRole {
*/ */
String getName(); String getName();
/**
* Gets the mention of this role.
* @return this role's mention.
*/
String getAsMention();
/** /**
* Whether this role is managed by an external integration. * Whether this role is managed by an external integration.
* @return true if the role is managed. * @return true if the role is managed.
@ -34,6 +40,12 @@ public interface InteractionRole {
*/ */
boolean isDefaultColor(); boolean isDefaultColor();
/**
* Whether this role can be given to other members by the current logged in bot.
* @return true if this role can be interacted with by the current bot user.
*/
boolean canInteract();
/** /**
* Gets the ID of this role. * Gets the ID of this role.
* @return this role's ID. * @return this role's ID.

View File

@ -15,6 +15,11 @@ public class InteractionRoleImpl implements InteractionRole {
return role.getName(); return role.getName();
} }
@Override
public String getAsMention() {
return role.getAsMention();
}
@Override @Override
public boolean isManaged() { public boolean isManaged() {
return role.isManaged(); return role.isManaged();
@ -35,6 +40,11 @@ public class InteractionRoleImpl implements InteractionRole {
return role.getColorRaw() == Role.DEFAULT_COLOR_RAW; return role.getColorRaw() == Role.DEFAULT_COLOR_RAW;
} }
@Override
public boolean canInteract() {
return role.getGuild().getSelfMember().canInteract(role);
}
public Role getJdaObject() { public Role getJdaObject() {
return role; return role;
} }
@ -43,4 +53,9 @@ public class InteractionRoleImpl implements InteractionRole {
public String getId() { public String getId() {
return role.getId(); return role.getId();
} }
@Override
public String toString() {
return "InteractionRoleImpl{name=" + getName() + ",id=" + getId() + "}";
}
} }