mirror of
https://github.com/JonasunderscoreJones/ZtereoMUSIC.git
synced 2025-10-26 04:49:18 +01:00
new: fart + actual fix
This commit is contained in:
parent
3959b82dcf
commit
a1c2ab3551
3 changed files with 53 additions and 8 deletions
|
|
@ -46,13 +46,10 @@ public class ZtereoMUSIC {
|
||||||
return ZtereoMUSIC.INSTANCE;
|
return ZtereoMUSIC.INSTANCE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@SneakyThrows({ FileNotFoundException.class, LoginException.class, InterruptedException.class, IOException.class })
|
@SneakyThrows({ FileNotFoundException.class, LoginException.class, InterruptedException.class, IOException.class }) public static void main(String[] args) {
|
||||||
public static void main(String[] args) {
|
|
||||||
ZtereoMUSIC ztereoMUSIC = ZtereoMUSIC.getInstance();
|
ZtereoMUSIC ztereoMUSIC = ZtereoMUSIC.getInstance();
|
||||||
|
|
||||||
EnumSet<GatewayIntent> intents = EnumSet.of(GatewayIntent.GUILD_MESSAGES,
|
EnumSet<GatewayIntent> intents = EnumSet.of(GatewayIntent.GUILD_MESSAGES, GatewayIntent.GUILD_VOICE_STATES, GatewayIntent.GUILD_EMOJIS);
|
||||||
GatewayIntent.GUILD_VOICE_STATES,
|
|
||||||
GatewayIntent.GUILD_EMOJIS);
|
|
||||||
|
|
||||||
ztereoMUSIC.setConfig(Config.loadFrom("./config.json5"));
|
ztereoMUSIC.setConfig(Config.loadFrom("./config.json5"));
|
||||||
ztereoMUSIC.setJda(JDABuilder.createDefault(ztereoMUSIC.getConfig().getPropreties().get("token"), intents)
|
ztereoMUSIC.setJda(JDABuilder.createDefault(ztereoMUSIC.getConfig().getPropreties().get("token"), intents)
|
||||||
|
|
@ -90,6 +87,9 @@ public class ZtereoMUSIC {
|
||||||
Queue queue = new Queue();
|
Queue queue = new Queue();
|
||||||
this.getCommandMap().put(queue.getMeta().getName(), queue);
|
this.getCommandMap().put(queue.getMeta().getName(), queue);
|
||||||
|
|
||||||
|
Fart fart = new Fart();
|
||||||
|
this.getCommandMap().put(fart.getMeta().getName(), fart);
|
||||||
|
|
||||||
for (String commandName : this.getCommandMap().keySet()) {
|
for (String commandName : this.getCommandMap().keySet()) {
|
||||||
for (String aliasName : this.getCommandMap().get(commandName).getMeta().getAliases()) {
|
for (String aliasName : this.getCommandMap().get(commandName).getMeta().getAliases()) {
|
||||||
System.out.println("Loaded alias \"" + aliasName + "\" for command: " + commandName);
|
System.out.println("Loaded alias \"" + aliasName + "\" for command: " + commandName);
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,8 @@ public class TrackManager extends AudioEventAdapter {
|
||||||
public final List<AudioTrack> trackQueue = new ArrayList<>();
|
public final List<AudioTrack> trackQueue = new ArrayList<>();
|
||||||
private final @Getter AudioPlayer player;
|
private final @Getter AudioPlayer player;
|
||||||
private String hasRetriedId;
|
private String hasRetriedId;
|
||||||
private @Getter @Setter MessageChannel infoChannel;
|
private @Getter
|
||||||
|
@Setter MessageChannel infoChannel;
|
||||||
|
|
||||||
public TrackManager(AudioPlayerManager playerManager, MessageChannel infoChannel) {
|
public TrackManager(AudioPlayerManager playerManager, MessageChannel infoChannel) {
|
||||||
this.player = playerManager.createPlayer();
|
this.player = playerManager.createPlayer();
|
||||||
|
|
@ -88,7 +89,6 @@ public class TrackManager extends AudioEventAdapter {
|
||||||
switch (endReason) {
|
switch (endReason) {
|
||||||
case FINISHED -> playNext();
|
case FINISHED -> playNext();
|
||||||
|
|
||||||
//todo: warning: this will create an infinite loop if a specific video has issues...
|
|
||||||
case LOAD_FAILED -> {
|
case LOAD_FAILED -> {
|
||||||
String identifier;
|
String identifier;
|
||||||
String trackTitle = track.getInfo().title;
|
String trackTitle = track.getInfo().title;
|
||||||
|
|
@ -118,7 +118,8 @@ public class TrackManager extends AudioEventAdapter {
|
||||||
|
|
||||||
@Override public void onTrackException(AudioPlayer player, AudioTrack track, FriendlyException exception) {
|
@Override public void onTrackException(AudioPlayer player, AudioTrack track, FriendlyException exception) {
|
||||||
// infoChannel.sendMessage("Uh oh, a track did something strange. Ask the owner to check for errors in console. ").queue();
|
// infoChannel.sendMessage("Uh oh, a track did something strange. Ask the owner to check for errors in console. ").queue();
|
||||||
System.out.println(exception.getCause().getMessage());
|
// System.out.println(exception.getCause().getMessage());
|
||||||
|
onTrackEnd(player, track, AudioTrackEndReason.LOAD_FAILED);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public void onTrackStuck(AudioPlayer player, AudioTrack track, long thresholdMs) {
|
@Override public void onTrackStuck(AudioPlayer player, AudioTrack track, long thresholdMs) {
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,44 @@
|
||||||
|
package codes.ztereohype.ztereomusic.command.commands;
|
||||||
|
|
||||||
|
import codes.ztereohype.ztereomusic.ZtereoMUSIC;
|
||||||
|
import codes.ztereohype.ztereomusic.audio.CustomAudioLoadResultHandler;
|
||||||
|
import codes.ztereohype.ztereomusic.audio.TrackManager;
|
||||||
|
import codes.ztereohype.ztereomusic.audio.TrackManagers;
|
||||||
|
import codes.ztereohype.ztereomusic.command.Command;
|
||||||
|
import codes.ztereohype.ztereomusic.command.CommandMeta;
|
||||||
|
import codes.ztereohype.ztereomusic.command.permissions.VoiceChecks;
|
||||||
|
import net.dv8tion.jda.api.entities.VoiceChannel;
|
||||||
|
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
public class Fart implements Command {
|
||||||
|
private final CommandMeta meta;
|
||||||
|
|
||||||
|
public Fart() {
|
||||||
|
this.meta = CommandMeta.builder()
|
||||||
|
.name("fart")
|
||||||
|
.description("A command to get fart with extra reverb")
|
||||||
|
.aliases(new String[] { "shit" })
|
||||||
|
.isNsfw(false)
|
||||||
|
.isHidden(false)
|
||||||
|
.checks(new VoiceChecks[] { VoiceChecks.USER_CONNECTED, VoiceChecks.SAME_VC_IF_CONNECTED })
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public CommandMeta getMeta() {
|
||||||
|
return this.meta;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void execute(MessageReceivedEvent messageEvent, String[] args) {
|
||||||
|
|
||||||
|
System.out.println("dsijfgajsdgu");
|
||||||
|
VoiceChannel voiceChannel = Objects.requireNonNull(messageEvent.getMember().getVoiceState()).getChannel();
|
||||||
|
|
||||||
|
TrackManager trackManager = TrackManagers.getOrCreateGuildTrackManager(messageEvent.getGuild(), messageEvent.getChannel(), voiceChannel);
|
||||||
|
|
||||||
|
ZtereoMUSIC.getInstance()
|
||||||
|
.getPlayerManager()
|
||||||
|
.loadItem("https://www.youtube.com/watch?v=ITEm5v4xw3o", new CustomAudioLoadResultHandler(trackManager, messageEvent.getChannel()));
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue