Search in sources :

Example 1 with Server

use of gartham.c10ver.economy.Server in project c10ver by Gartham.

the class CloverGuildMemberAddRoleConsumer method consume.

@Override
public boolean consume(GuildMemberRoleAddEvent event, InputProcessor<? extends GuildMemberRoleAddEvent> processor, InputConsumer<GuildMemberRoleAddEvent> consumer) {
    var e = (GuildMemberRoleAddEvent) event;
    Server s = clover.getEconomy().getServer(e.getGuild().getId());
    var role = s.getVoteRole();
    if (role != null)
        for (Role r : e.getRoles()) if (r.getId().equals(role)) {
            try {
                e.getGuild().removeRoleFromMember(e.getMember(), r).queue();
            } catch (Exception er) {
                System.err.println("An error occurred while attempting to remove the vote role from a user!");
                er.printStackTrace();
            }
            clover.getVoteManager().handleVoteRoleAdded(e.getMember());
            break;
        }
    return false;
}
Also used : Role(net.dv8tion.jda.api.entities.Role) Server(gartham.c10ver.economy.Server) GuildMemberRoleAddEvent(net.dv8tion.jda.api.events.guild.member.GuildMemberRoleAddEvent)

Aggregations

Server (gartham.c10ver.economy.Server)1 Role (net.dv8tion.jda.api.entities.Role)1 GuildMemberRoleAddEvent (net.dv8tion.jda.api.events.guild.member.GuildMemberRoleAddEvent)1