fix: update lavasrc 4.8.3, disable broken spotify, JDA 6.4.2 migration

This commit is contained in:
loki5512344 2026-07-03 21:04:35 +02:00
parent 108f63f7ec
commit 42948520e8
22 changed files with 129 additions and 45 deletions

View file

@ -95,6 +95,9 @@
</module>
<module name="NoFinalizer"/>
<module name="GenericWhitespace"/>
<module name="DefaultComesLast"/>
<module name="SimplifyBooleanReturn"/>
<module name="AvoidStarImport"/>
<module name="Indentation">
<property name="basicOffset" value="2"/>
<property name="braceAdjustment" value="0"/>

View file

@ -1,6 +1,6 @@
[versions]
jda = "5.6.1"
lavaplayer = "2.2.3"
jda = "6.4.2"
lavaplayer = "2.2.6"
lavalinkClient = "3.4.0"
dotenv = "3.2.0"
slf4j = "2.1.0-alpha1"

View file

@ -14,7 +14,7 @@ plugins:
- "ytsearch:\"%ISRC%\""
- "ytsearch:%QUERY%"
sources:
spotify: true
spotify: false
applemusic: true
deezer: false
yandexmusic: false
@ -33,7 +33,7 @@ lavalink:
plugins:
- dependency: "dev.lavalink.youtube:youtube-plugin:1.18.1"
repository: "https://maven.lavalink.dev/releases"
- dependency: "com.github.topi314.lavasrc:lavasrc-plugin:4.8.1"
- dependency: "com.github.topi314.lavasrc:lavasrc-plugin:4.8.3"
repository: "https://maven.topi.wtf/releases"
server:
password: "Hch4HiVCxkKs9JPiSnrt4Q"

View file

@ -165,6 +165,10 @@ public class BotInitializer {
GatewayIntent.GUILD_VOICE_STATES)
.enableCache(CacheFlag.VOICE_STATE);
if (lavalinkManager.getClient() != null) {
builder.setVoiceDispatchInterceptor(new JDAVoiceUpdateListener(lavalinkManager.getClient()));
}
builder.addEventListeners(new RadioBotListener(radioManager));
return builder.build();

View file

@ -1,6 +1,6 @@
package creator.loki.feature.counter;
import java.util.*;
import java.util.List;
import creator.loki.feature.config.repository.ConfigRepository;
import creator.loki.feature.counter.repository.CounterStatsRepository;

View file

@ -5,10 +5,31 @@ import creator.loki.config.BotConfig;
import creator.loki.core.registry.CommandRegistrar;
import creator.loki.core.registry.CommandRegistry;
import creator.loki.core.security.CooldownManager;
import creator.loki.feature.entertainment.commands.*;
import creator.loki.feature.entertainment.commands.BoykisserCommand;
import creator.loki.feature.entertainment.commands.CoinCommand;
import creator.loki.feature.entertainment.commands.DiceCommand;
import creator.loki.feature.entertainment.commands.EightBallCommand;
import creator.loki.feature.entertainment.commands.FatCommand;
import creator.loki.feature.entertainment.commands.GayCommand;
import creator.loki.feature.entertainment.commands.GlazbobaCommand;
import creator.loki.feature.entertainment.commands.IqCommand;
import creator.loki.feature.entertainment.commands.MemeCommand;
import creator.loki.feature.entertainment.commands.MustacheCommand;
import creator.loki.feature.entertainment.commands.PpCommand;
import creator.loki.feature.entertainment.commands.RandomChoiceCommand;
import creator.loki.feature.entertainment.commands.RateCommand;
import creator.loki.feature.ship.ShipCommand;
import creator.loki.feature.ship.repository.ShipPairRepository;
import creator.loki.feature.social.commands.*;
import creator.loki.feature.social.commands.ComplimentCommand;
import creator.loki.feature.social.commands.CuddleCommand;
import creator.loki.feature.social.commands.FeedCommand;
import creator.loki.feature.social.commands.RoastCommand;
import creator.loki.feature.social.commands.HugCommand;
import creator.loki.feature.social.commands.KissCommand;
import creator.loki.feature.social.commands.PatCommand;
import creator.loki.feature.social.commands.PokeCommand;
import creator.loki.feature.social.commands.SlapCommand;
import creator.loki.feature.social.commands.TickleCommand;
public class EntertainmentCommandRegistrar implements CommandRegistrar {
private final CooldownManager cooldownManager;

View file

@ -15,7 +15,8 @@ import creator.loki.embed.HelpCategories;
import net.dv8tion.jda.api.Permission;
import net.dv8tion.jda.api.events.interaction.component.StringSelectInteractionEvent;
import net.dv8tion.jda.api.hooks.ListenerAdapter;
import net.dv8tion.jda.api.interactions.components.selections.StringSelectMenu;
import net.dv8tion.jda.api.components.actionrow.ActionRow;
import net.dv8tion.jda.api.components.selections.StringSelectMenu;
@Singleton
public class HelpMenuHandler extends ListenerAdapter {
@ -94,7 +95,7 @@ public class HelpMenuHandler extends ListenerAdapter {
net.dv8tion.jda.api.entities.emoji.Emoji.fromUnicode(emoji));
});
event.editMessageEmbeds(embed.build()).setActionRow(menuBuilder.build()).queue();
event.editMessageEmbeds(embed.build()).setComponents(ActionRow.of(menuBuilder.build())).queue();
}
private EmbedFactory createCategoryEmbed(

View file

@ -13,7 +13,8 @@ import creator.loki.embed.EmbedFactory;
import creator.loki.embed.HelpCategories;
import net.dv8tion.jda.api.Permission;
import net.dv8tion.jda.api.entities.User;
import net.dv8tion.jda.api.interactions.components.selections.StringSelectMenu;
import net.dv8tion.jda.api.components.actionrow.ActionRow;
import net.dv8tion.jda.api.components.selections.StringSelectMenu;
public class HelpCommand implements Command {
private final CommandRegistry registry;
@ -74,7 +75,7 @@ public class HelpCommand implements Command {
net.dv8tion.jda.api.entities.emoji.Emoji.fromUnicode(emoji));
});
context.getChannel().sendMessageEmbeds(embed.build()).addActionRow(menuBuilder.build()).queue();
context.getChannel().sendMessageEmbeds(embed.build()).addComponents(ActionRow.of(menuBuilder.build())).queue();
}
private EmbedFactory createMainPage(

View file

@ -2,7 +2,7 @@ package creator.loki.feature.leaderboard;
import java.util.List;
import net.dv8tion.jda.api.interactions.components.buttons.Button;
import net.dv8tion.jda.api.components.buttons.Button;
/** Кнопки для таблицы лидеров */
public class LeaderboardButtons {

View file

@ -5,6 +5,7 @@ import java.util.concurrent.TimeUnit;
import creator.loki.command.Command;
import creator.loki.command.CommandContext;
import creator.loki.feature.level.service.LeaderboardService;
import net.dv8tion.jda.api.components.actionrow.ActionRow;
/** Команда таблицы лидеров (рефакторинг: 241 → 50 строк) */
public class LeaderboardCommand implements Command {
@ -49,7 +50,7 @@ public class LeaderboardCommand implements Command {
context
.getChannel()
.sendMessageEmbeds(embed)
.setActionRow(buttons)
.addComponents(ActionRow.of(buttons))
.queue(
message -> {
// Удаляем кнопки через 5 минут

View file

@ -10,7 +10,8 @@ import creator.loki.feature.level.domain.UserStats;
import creator.loki.feature.level.repository.UserStatsRepository;
import creator.loki.util.LoggerDecorator;
import net.dv8tion.jda.api.Permission;
import net.dv8tion.jda.api.interactions.components.buttons.Button;
import net.dv8tion.jda.api.components.actionrow.ActionRow;
import net.dv8tion.jda.api.components.buttons.Button;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -116,10 +117,11 @@ public class ResetLevelsCommand implements Command {
false)
.withFooter("Подтвердите действие нажатием кнопки ниже")
.build())
.setActionRow(
.addComponents(
ActionRow.of(
Button.success(
"reset_levels_confirm:" + context.getAuthor().getId(), "✅ Подтвердить сброс"),
Button.danger("reset_levels_cancel:" + context.getAuthor().getId(), "❌ Отмена"))
Button.danger("reset_levels_cancel:" + context.getAuthor().getId(), "❌ Отмена")))
.queue();
}

View file

@ -3,7 +3,11 @@ package creator.loki.feature.level.repository;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.*;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import creator.loki.database.Database;
import creator.loki.feature.level.domain.UserStats;

View file

@ -18,7 +18,10 @@ import creator.loki.feature.moderation.commands.warn.WarningsHistoryCommand;
import creator.loki.feature.moderation.repository.ActiveMuteRepository;
import creator.loki.feature.moderation.repository.ModerationCaseRepository;
import creator.loki.feature.moderation.repository.WarningRepository;
import creator.loki.feature.role.*;
import creator.loki.feature.role.CustomRoleManager;
import creator.loki.feature.role.DeleteRoleCommand;
import creator.loki.feature.role.EditRoleCommand;
import creator.loki.feature.role.MyRolesCommand;
import creator.loki.feature.role.commands.CreateRoleCommand;
public class ModerationCommandRegistrar implements CommandRegistrar {

View file

@ -106,7 +106,7 @@ public class MusicBotPlayHandler {
g.getAudioManager().openAudioConnection(vc);
}
for (int i = 0; i < 30; i++) {
for (int i = 0; i < 10; i++) {
if (g.getMember(g.getJDA().getSelfUser()).getVoiceState().inAudioChannel()) break;
try {
Thread.sleep(200);
@ -116,7 +116,7 @@ public class MusicBotPlayHandler {
}
Link link = lm.getOrCreateLink(g.getIdLong());
for (int i = 0; i < 30; i++) {
for (int i = 0; i < 10; i++) {
if (link.getCachedPlayer() != null) return;
try {
Thread.sleep(200);

View file

@ -176,11 +176,11 @@ public class TrackScheduler {
}
private void sendTrackDelayed(Link link, Track track, int attempt) {
if (attempt > 10) return;
if (attempt > 5) return;
if (link.getCachedPlayer() == null) {
manager
.getExecutor()
.schedule(() -> sendTrackDelayed(link, track, attempt + 1), 500, TimeUnit.MILLISECONDS);
.schedule(() -> sendTrackDelayed(link, track, attempt + 1), 300, TimeUnit.MILLISECONDS);
return;
}
link.createOrUpdatePlayer()
@ -189,12 +189,12 @@ public class TrackScheduler {
.subscribe(
null,
err -> {
if (attempt < 10) {
if (attempt < 5) {
manager
.getExecutor()
.schedule(
() -> sendTrackDelayed(link, track, attempt + 1),
1000,
500,
TimeUnit.MILLISECONDS);
}
});

View file

@ -84,7 +84,7 @@ public class PlayCommand implements Command {
if (!guild.getAudioManager().isConnected()) {
guild.getAudioManager().openAudioConnection(vc);
}
for (int i = 0; i < 30; i++) {
for (int i = 0; i < 10; i++) {
if (guild.getMember(guild.getJDA().getSelfUser()).getVoiceState().inAudioChannel()) break;
try {
Thread.sleep(200);
@ -93,7 +93,7 @@ public class PlayCommand implements Command {
}
}
var link = lm.getOrCreateLink(guild.getIdLong());
for (int i = 0; i < 30; i++) {
for (int i = 0; i < 10; i++) {
if (link.getCachedPlayer() != null) break;
try {
Thread.sleep(200);

View file

@ -1,7 +1,11 @@
package creator.loki.feature.profile;
import java.awt.*;
import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Font;
import java.awt.FontFormatException;
import java.awt.Graphics2D;
import java.awt.RenderingHints;
import java.awt.geom.Ellipse2D;
import java.awt.image.BufferedImage;
import java.io.IOException;

View file

@ -8,12 +8,9 @@ import creator.loki.feature.music.manage.GuildMusicManager;
import creator.loki.util.LoggerDecorator;
import dev.arbjerg.lavalink.client.AbstractAudioLoadResultHandler;
import dev.arbjerg.lavalink.client.Link;
import dev.arbjerg.lavalink.client.player.Track;
import dev.arbjerg.lavalink.client.player.TrackLoaded;
import net.dv8tion.jda.api.JDA;
import net.dv8tion.jda.api.entities.Guild;
import net.dv8tion.jda.api.entities.Member;
import net.dv8tion.jda.api.entities.channel.concrete.VoiceChannel;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -53,6 +50,25 @@ public class RadioManager {
guild.getJDA().getDirectAudioController().connect(
guild.getVoiceChannelById(channelId));
for (int i = 0; i < 10; i++) {
if (guild.getMember(guild.getJDA().getSelfUser()).getVoiceState().inAudioChannel()) break;
try {
Thread.sleep(200);
} catch (InterruptedException e) {
return;
}
}
var link = lavalinkManager.getOrCreateLink(guildId);
for (int i = 0; i < 10; i++) {
if (link.getCachedPlayer() != null) break;
try {
Thread.sleep(200);
} catch (InterruptedException e) {
return;
}
}
var mm = new GuildMusicManager(guildId, lavalinkManager, null);
state.musicManager = mm;
@ -130,8 +146,27 @@ public class RadioManager {
return radioJda;
}
public int getVolume(long guildId) {
GuildRadioState state = radioStates.get(guildId);
return state != null ? state.volume : 100;
}
public void setVolume(long guildId, int volume) {
GuildRadioState state = radioStates.computeIfAbsent(guildId, id -> new GuildRadioState());
state.volume = Math.max(0, Math.min(100, volume));
if (lavalinkManager != null) {
var link = lavalinkManager.getClient().getLinkIfCached(guildId);
if (link != null && link.getCachedPlayer() != null) {
link.createOrUpdatePlayer()
.setVolume(state.volume)
.subscribe(null, err -> logger.warn("Lavalink: {}", err.getMessage()));
}
}
}
private static class GuildRadioState {
String streamUrl;
GuildMusicManager musicManager;
int volume = 100;
}
}

View file

@ -1,6 +1,6 @@
package creator.loki.feature.role;
import java.util.*;
import java.util.List;
import creator.loki.feature.role.repository.CustomRoleRepository;

View file

@ -1,6 +1,9 @@
package creator.loki.feature.serverstats;
import java.awt.*;
import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics2D;
import java.awt.RenderingHints;
import java.awt.image.BufferedImage;
import java.io.ByteArrayOutputStream;
import java.time.format.DateTimeFormatter;

View file

@ -8,9 +8,10 @@ import net.dv8tion.jda.api.entities.Member;
import net.dv8tion.jda.api.entities.channel.concrete.VoiceChannel;
import net.dv8tion.jda.api.events.interaction.component.ButtonInteractionEvent;
import net.dv8tion.jda.api.hooks.ListenerAdapter;
import net.dv8tion.jda.api.interactions.components.text.TextInput;
import net.dv8tion.jda.api.interactions.components.text.TextInputStyle;
import net.dv8tion.jda.api.interactions.modals.Modal;
import net.dv8tion.jda.api.components.label.Label;
import net.dv8tion.jda.api.components.textinput.TextInput;
import net.dv8tion.jda.api.components.textinput.TextInputStyle;
import net.dv8tion.jda.api.modals.Modal;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -91,7 +92,7 @@ public class VoiceButtonHandler extends ListenerAdapter {
private void handleLimit(ButtonInteractionEvent event, VoiceChannel channel) {
TextInput limitInput =
TextInput.create("limit", "Лимит пользователей", TextInputStyle.SHORT)
TextInput.create("limit", TextInputStyle.SHORT)
.setPlaceholder("0-99 (0 = без лимита)")
.setRequired(true)
.setMinLength(1)
@ -101,7 +102,7 @@ public class VoiceButtonHandler extends ListenerAdapter {
Modal modal =
Modal.create("voice_limit:" + channel.getId(), "Установить лимит")
.addActionRow(limitInput)
.addComponents(Label.of("Лимит пользователей", limitInput))
.build();
event.replyModal(modal).queue();
@ -109,7 +110,7 @@ public class VoiceButtonHandler extends ListenerAdapter {
private void handleRename(ButtonInteractionEvent event, VoiceChannel channel) {
TextInput nameInput =
TextInput.create("name", "Новое название", TextInputStyle.SHORT)
TextInput.create("name", TextInputStyle.SHORT)
.setPlaceholder("Введите название канала")
.setRequired(true)
.setMinLength(1)
@ -119,7 +120,7 @@ public class VoiceButtonHandler extends ListenerAdapter {
Modal modal =
Modal.create("voice_rename:" + channel.getId(), "Переименовать канал")
.addActionRow(nameInput)
.addComponents(Label.of("Новое название", nameInput))
.build();
event.replyModal(modal).queue();
@ -127,7 +128,7 @@ public class VoiceButtonHandler extends ListenerAdapter {
private void handleBitrate(ButtonInteractionEvent event, VoiceChannel channel) {
TextInput bitrateInput =
TextInput.create("bitrate", "Битрейт (kbps)", TextInputStyle.SHORT)
TextInput.create("bitrate", TextInputStyle.SHORT)
.setPlaceholder("8-384")
.setRequired(true)
.setMinLength(1)
@ -137,7 +138,7 @@ public class VoiceButtonHandler extends ListenerAdapter {
Modal modal =
Modal.create("voice_bitrate:" + channel.getId(), "🎨 Установить битрейт")
.addActionRow(bitrateInput)
.addComponents(Label.of("Битрейт (kbps)", bitrateInput))
.build();
event.replyModal(modal).queue();

View file

@ -12,7 +12,8 @@ import net.dv8tion.jda.api.Permission;
import net.dv8tion.jda.api.entities.Guild;
import net.dv8tion.jda.api.entities.Member;
import net.dv8tion.jda.api.entities.channel.concrete.VoiceChannel;
import net.dv8tion.jda.api.interactions.components.buttons.Button;
import net.dv8tion.jda.api.components.actionrow.ActionRow;
import net.dv8tion.jda.api.components.buttons.Button;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -144,7 +145,7 @@ public class VoiceChannelManager {
channel
.sendMessageEmbeds(embed.build())
.addActionRow(lockBtn, limitBtn, renameBtn, bitrateBtn, deleteBtn)
.addComponents(ActionRow.of(lockBtn, limitBtn, renameBtn, bitrateBtn, deleteBtn))
.queue();
}