Fix channel position
This commit is contained in:
parent
023afb7323
commit
1a4899c1cf
@ -17,12 +17,14 @@ import net.dv8tion.jda.api.events.guild.member.GuildMemberJoinEvent;
|
|||||||
import net.dv8tion.jda.api.events.guild.member.GuildMemberRoleRemoveEvent;
|
import net.dv8tion.jda.api.events.guild.member.GuildMemberRoleRemoveEvent;
|
||||||
import net.dv8tion.jda.api.events.guild.voice.GuildVoiceJoinEvent;
|
import net.dv8tion.jda.api.events.guild.voice.GuildVoiceJoinEvent;
|
||||||
import net.dv8tion.jda.api.events.guild.voice.GuildVoiceLeaveEvent;
|
import net.dv8tion.jda.api.events.guild.voice.GuildVoiceLeaveEvent;
|
||||||
|
import net.dv8tion.jda.api.events.guild.voice.GuildVoiceMoveEvent;
|
||||||
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||||
import net.dv8tion.jda.api.exceptions.InsufficientPermissionException;
|
import net.dv8tion.jda.api.exceptions.InsufficientPermissionException;
|
||||||
import net.dv8tion.jda.api.hooks.ListenerAdapter;
|
import net.dv8tion.jda.api.hooks.ListenerAdapter;
|
||||||
import net.dv8tion.jda.api.managers.GuildManager;
|
import net.dv8tion.jda.api.managers.GuildManager;
|
||||||
import org.apache.logging.log4j.LogManager;
|
import org.apache.logging.log4j.LogManager;
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.springframework.context.ApplicationContext;
|
import org.springframework.context.ApplicationContext;
|
||||||
|
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
@ -149,6 +151,13 @@ public class BotListener extends ListenerAdapter {
|
|||||||
autoVoiceChannel.leave(event.getChannelLeft());
|
autoVoiceChannel.leave(event.getChannelLeft());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onGuildVoiceMove(@NotNull GuildVoiceMoveEvent event) {
|
||||||
|
super.onGuildVoiceMove(event);
|
||||||
|
AutoVoiceChannel autoVoiceChannel = AutoVoiceChannel.getInstance(event.getGuild());
|
||||||
|
autoVoiceChannel.leave(event.getChannelLeft());
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onMessageReceived(MessageReceivedEvent event) {
|
public void onMessageReceived(MessageReceivedEvent event) {
|
||||||
|
|
||||||
@ -206,6 +215,7 @@ public class BotListener extends ListenerAdapter {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onGuildJoin(GuildJoinEvent event) {
|
public void onGuildJoin(GuildJoinEvent event) {
|
||||||
logger.info("Join new guild! (" + event.getGuild().getName() + " " + event.getGuild().getMembers().size() + " Members)");
|
logger.info("Join new guild! (" + event.getGuild().getName() + " " + event.getGuild().getMembers().size() + " Members)");
|
||||||
|
@ -42,7 +42,8 @@ public class AutoVoiceChannel {
|
|||||||
int next = getNextNumber();
|
int next = getNextNumber();
|
||||||
String title = pref.getAutoVoiceChannelTitle();
|
String title = pref.getAutoVoiceChannelTitle();
|
||||||
title = title.replace("@count", Integer.toString(next));
|
title = title.replace("@count", Integer.toString(next));
|
||||||
newChannel.getManager().setName(title).queue();
|
newChannel.getManager().setName(title).setPosition(voiceChannel.getPosition()).queue();
|
||||||
|
|
||||||
createdChannels.put(next, newChannel.getId());
|
createdChannels.put(next, newChannel.getId());
|
||||||
moveMembers(voiceChannel.getMembers(), newChannel);
|
moveMembers(voiceChannel.getMembers(), newChannel);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user