Search in sources :

Example 1 with Tempchannel

use of de.c0debase.bot.tempchannel.Tempchannel in project c0debaseBot by Biospheere.

the class ReadyListener method onReady.

@Override
public void onReady(ReadyEvent event) {
    super.onReady(event);
    event.getJDA().getGuilds().get(0).getMembers().forEach(member -> {
        if (!member.getUser().isBot()) {
            CodebaseBot.getInstance().getLevelManager().load(member.getUser().getId());
            if (CodebaseBot.getInstance().getLevelManager().getLevelUser(member.getUser().getId()).getLevel() >= 3 && !member.getGuild().getRolesByName("Projekt", true).isEmpty()) {
                Role role = member.getGuild().getRolesByName("Projekt", true).get(0);
                if (PermissionUtil.canInteract(member.getGuild().getSelfMember(), role)) {
                    member.getGuild().getController().addRolesToMember(member, role).queue();
                }
            }
        }
    });
    Set<Class<? extends ListenerAdapter>> classes = new Reflections("de.c0debase.bot.listener").getSubTypesOf(ListenerAdapter.class);
    classes.forEach(listenerClass -> {
        if (!listenerClass.getName().equals(this.getClass().getName())) {
            try {
                event.getJDA().addEventListener(listenerClass.newInstance());
            } catch (Exception ex) {
                ex.printStackTrace();
            }
        }
    });
    for (VoiceChannel voiceChannel : event.getJDA().getGuilds().get(0).getVoiceChannels()) {
        String name = ("temp-" + voiceChannel.getName().toLowerCase()).replaceAll("\\s+", "-");
        final TextChannel textChannel = voiceChannel.getGuild().getTextChannelsByName(name, true).isEmpty() ? null : voiceChannel.getGuild().getTextChannelsByName(name, true).get(0);
        if (textChannel == null) {
            CodebaseBot.getInstance().getTempchannels().put(voiceChannel.getId(), new Tempchannel());
        } else {
            Tempchannel tempchannel = new Tempchannel(textChannel);
            tempchannel.onLoad(textChannel, voiceChannel);
            CodebaseBot.getInstance().getTempchannels().put(voiceChannel.getId(), tempchannel);
        }
    }
    CodebaseBot.getInstance().getLevelManager().startInviteChecker();
}
Also used : Role(net.dv8tion.jda.core.entities.Role) ListenerAdapter(net.dv8tion.jda.core.hooks.ListenerAdapter) TextChannel(net.dv8tion.jda.core.entities.TextChannel) VoiceChannel(net.dv8tion.jda.core.entities.VoiceChannel) Tempchannel(de.c0debase.bot.tempchannel.Tempchannel) Reflections(org.reflections.Reflections)

Example 2 with Tempchannel

use of de.c0debase.bot.tempchannel.Tempchannel in project c0debaseBot by Biospheere.

the class GuildVoiceListener method onVoiceChannelCreate.

@Override
public void onVoiceChannelCreate(VoiceChannelCreateEvent event) {
    super.onVoiceChannelCreate(event);
    CodebaseBot.getInstance().getTempchannels().put(event.getChannel().getId(), new Tempchannel());
}
Also used : Tempchannel(de.c0debase.bot.tempchannel.Tempchannel)

Aggregations

Tempchannel (de.c0debase.bot.tempchannel.Tempchannel)2 Role (net.dv8tion.jda.core.entities.Role)1 TextChannel (net.dv8tion.jda.core.entities.TextChannel)1 VoiceChannel (net.dv8tion.jda.core.entities.VoiceChannel)1 ListenerAdapter (net.dv8tion.jda.core.hooks.ListenerAdapter)1 Reflections (org.reflections.Reflections)1