本文整理汇总了Java中net.dv8tion.jda.core.events.role.RoleDeleteEvent类的典型用法代码示例。如果您正苦于以下问题:Java RoleDeleteEvent类的具体用法?Java RoleDeleteEvent怎么用?Java RoleDeleteEvent使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
RoleDeleteEvent类属于net.dv8tion.jda.core.events.role包,在下文中一共展示了RoleDeleteEvent类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onRoleDelete
import net.dv8tion.jda.core.events.role.RoleDeleteEvent; //导入依赖的package包/类
@Override
public void onRoleDelete(RoleDeleteEvent event) {
GuildTransformer transformer = GuildController.fetchGuild(avaire, event.getGuild());
if (transformer == null || transformer.getSelfAssignableRoles().isEmpty()) {
return;
}
if (!transformer.getSelfAssignableRoles().containsKey(event.getRole().getId())) {
return;
}
try {
transformer.getSelfAssignableRoles().remove(event.getRole().getId());
avaire.getDatabase().newQueryBuilder(Constants.GUILD_TABLE_NAME)
.where("id", event.getGuild().getId())
.update(statement -> {
statement.set("claimable_roles", AvaIre.GSON.toJson(transformer.getSelfAssignableRoles()), true);
});
} catch (SQLException e) {
e.printStackTrace();
}
}
示例2: onRoleDelete
import net.dv8tion.jda.core.events.role.RoleDeleteEvent; //导入依赖的package包/类
@Override
public void onRoleDelete(RoleDeleteEvent e) {
GuildObject g = GuildObject.guildMap.get(e.getGuild().getId());
String roleId = e.getRole().getId();
// Joinable
if (g.isJoinableRole(e.getRole().getId())) {
g.removeJoinableRole(e.getRole().getId());
}
// Auto assign
if (g.getConfig().getAutoAssignRoleId().equals(roleId)) {
g.getConfig().setAutoAssignRoleId("");
}
// DJ
if (g.getConfig().getDjRoleId().equals(roleId)) {
g.getConfig().setDjRoleId("");
}
// Mute
if (g.getConfig().getMutedRoleId().equals(roleId)) {
g.getConfig().setMutedRoleId("");
}
}
示例3: handleRoleDeletion
import net.dv8tion.jda.core.events.role.RoleDeleteEvent; //导入依赖的package包/类
public static void handleRoleDeletion(RoleDeleteEvent event) {
File file = new File("data/ranks/" + event.getGuild().getId() + ".dat");
Configuration ranks = new Configuration(file);
Role role = event.getRole();
if (!isRank(role)) return;
ranks.unset(role.getName());
}
示例4: handleInternally
import net.dv8tion.jda.core.events.role.RoleDeleteEvent; //导入依赖的package包/类
@Override
protected Long handleInternally(JSONObject content)
{
final long guildId = content.getLong("guild_id");
if (api.getGuildLock().isLocked(guildId))
return guildId;
GuildImpl guild = (GuildImpl) api.getGuildMap().get(guildId);
if (guild == null)
{
api.getEventCache().cache(EventCache.Type.GUILD, guildId, () -> handle(responseNumber, allContent));
EventCache.LOG.debug("GUILD_ROLE_DELETE was received for a Guild that is not yet cached: {}", content);
return null;
}
final long roleId = content.getLong("role_id");
Role removedRole = guild.getRolesMap().remove(roleId);
if (removedRole == null)
{
api.getEventCache().cache(EventCache.Type.ROLE, roleId, () -> handle(responseNumber, allContent));
EventCache.LOG.debug("GUILD_ROLE_DELETE was received for a Role that is not yet cached: {}", content);
return null;
}
//Now that the role is removed from the Guild, remove it from all users.
for (Member m : guild.getMembersMap().valueCollection())
{
MemberImpl member = (MemberImpl) m;
member.getRoleSet().remove(removedRole);
}
api.getEventManager().handle(
new RoleDeleteEvent(
api, responseNumber,
removedRole));
api.getEventCache().clear(EventCache.Type.ROLE, roleId);
return null;
}
示例5: onRoleDelete
import net.dv8tion.jda.core.events.role.RoleDeleteEvent; //导入依赖的package包/类
@Override
public void onRoleDelete(RoleDeleteEvent event) {
CommandRanks.handleRoleDeletion(event);
}
示例6: onEvent
import net.dv8tion.jda.core.events.role.RoleDeleteEvent; //导入依赖的package包/类
@Override
public void onEvent(Event event) {
if (event instanceof ReconnectedEvent || event instanceof ResumedEvent) {
ConstellationManager.restartConstellation();
System.out.println("Constellation has been restarted due to a Discord reconnect.");
} else if (event instanceof GenericGuildEvent) {
GenericGuildEvent gge = ((GenericGuildEvent) event);
if (event instanceof GuildMemberJoinEvent) {
GuildMemberJoinEvent gmje = ((GuildMemberJoinEvent) gge);
List<BTBRole> roles = DbManager.readTeamRolesForGuild(Long.parseLong(gmje.getGuild().getId()));
for (BTBRole role : roles) {
List<BeamTeamUser> teamMembers = BeamManager.getTeamMembers(role.getTeamID());
for (BeamTeamUser member : teamMembers) {
if (null != member.social && StringUtils.isNotBlank(member.social.discord)) {
if (StringUtils.containsIgnoreCase(member.social.discord,
gmje.getMember().getUser().getName())) {
JDAManager.giveTeamRoleToUser(role, gmje.getMember().getUser());
break;
}
}
}
}
} else if (event instanceof GuildJoinEvent) {
GuildManager.getGuild(gge.getGuild());
System.out.println(String.format("%s has added the bot, they have been added to the database.",
gge.getGuild().getName()));
} else if (event instanceof GuildLeaveEvent) {
GuildManager.deleteGuild(Long.parseLong(gge.getGuild().getId()));
System.out.println(String.format(
"%s has removed the bot, they and all relevant records have been purged from the database.",
gge.getGuild().getName()));
}
} else if (event instanceof RoleDeleteEvent) {
// TODO: delete role config from DB
}
}
示例7: onRoleDelete
import net.dv8tion.jda.core.events.role.RoleDeleteEvent; //导入依赖的package包/类
public void onRoleDelete(RoleDeleteEvent event) {}