fdsg
This commit is contained in:
parent
14387062bd
commit
6e73bcb554
7 changed files with 27 additions and 31 deletions
|
|
@ -30,19 +30,23 @@ public class AudioManager {
|
||||||
AudioSourceManagers.registerRemoteSources(myManager);
|
AudioSourceManagers.registerRemoteSources(myManager);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Map<String, Map.Entry<AudioPlayer, TrackManager>> players = new HashMap<>();
|
public Map<String, Map.Entry<AudioPlayer, TrackManager>> players = new HashMap<>();
|
||||||
private final AudioPlayerManager myManager = new DefaultAudioPlayerManager();
|
private final AudioPlayerManager myManager = new DefaultAudioPlayerManager();
|
||||||
|
|
||||||
public boolean hasPlayer(Guild guild) {
|
public boolean hasPlayer(Guild guild) {
|
||||||
return players.containsKey(guild.getId());
|
return players.containsKey(guild.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void removePlayer(Guild g) {
|
public void removePlayer(Guild g) {
|
||||||
System.out.println(players.toString());
|
System.out.println(players.toString());
|
||||||
players.remove(g.getId());
|
players.remove(g.getId());
|
||||||
System.out.println(players.toString());
|
System.out.println(players.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Map<String, Map.Entry<AudioPlayer, TrackManager>> getPlayers () {
|
||||||
|
return players;
|
||||||
|
}
|
||||||
|
|
||||||
public AudioPlayer getPlayer(Guild guild) {
|
public AudioPlayer getPlayer(Guild guild) {
|
||||||
AudioPlayer p;
|
AudioPlayer p;
|
||||||
if (hasPlayer(guild)) {
|
if (hasPlayer(guild)) {
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ public class BanCommand implements Command {
|
||||||
event.getMessageEditor().getMessage(
|
event.getMessageEditor().getMessage(
|
||||||
MessageEditor.MessageType.INFO,
|
MessageEditor.MessageType.INFO,
|
||||||
"commands.moderation.ban.success.title",
|
"commands.moderation.ban.success.title",
|
||||||
"✅",
|
"",
|
||||||
"commands.moderation.ban.success.description",
|
"commands.moderation.ban.success.description",
|
||||||
victim.getUser().getName() + ".").build()).queue();
|
victim.getUser().getName() + ".").build()).queue();
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -74,7 +74,7 @@ public class BanCommand implements Command {
|
||||||
}
|
}
|
||||||
event.getTextChannel().sendMessage(event.getMessageEditor().getMessage(MessageEditor.MessageType.INFO,
|
event.getTextChannel().sendMessage(event.getMessageEditor().getMessage(MessageEditor.MessageType.INFO,
|
||||||
"commands.moderation.ban.success.title",
|
"commands.moderation.ban.success.title",
|
||||||
"✅",
|
"",
|
||||||
"commands.moderation.ban.massban.success.description",
|
"commands.moderation.ban.massban.success.description",
|
||||||
String.valueOf(event.getMessage().getMentionedMembers().size())).build()).queue();
|
String.valueOf(event.getMessage().getMentionedMembers().size())).build()).queue();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ package com.bbn.hadder.commands.music;
|
||||||
import com.bbn.hadder.audio.AudioManager;
|
import com.bbn.hadder.audio.AudioManager;
|
||||||
import com.bbn.hadder.commands.Command;
|
import com.bbn.hadder.commands.Command;
|
||||||
import com.bbn.hadder.commands.CommandEvent;
|
import com.bbn.hadder.commands.CommandEvent;
|
||||||
|
import com.bbn.hadder.utils.MessageEditor;
|
||||||
import com.sedmelluq.discord.lavaplayer.track.AudioTrack;
|
import com.sedmelluq.discord.lavaplayer.track.AudioTrack;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -17,35 +18,22 @@ public class InfoCommand implements Command {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void executed(String[] args, CommandEvent event) {
|
public void executed(String[] args, CommandEvent event) {
|
||||||
if (new AudioManager().hasPlayer(event.getGuild())) {
|
if (new AudioManager().hasPlayer(event.getGuild()) && new AudioManager().getPlayer(event.getGuild()).getPlayingTrack() == null) {
|
||||||
event.getTextChannel().sendMessage("Ja Player is auch wieder da");
|
|
||||||
}
|
|
||||||
if (new AudioManager().getPlayer(event.getGuild()).getPlayingTrack() == null) {
|
|
||||||
event.getTextChannel().sendMessage("Joo playing track net anwesend^^").queue();
|
|
||||||
}
|
|
||||||
if (!new AudioManager().hasPlayer(event.getGuild()) || new AudioManager().getPlayer(event.getGuild()).getPlayingTrack() == null) {
|
|
||||||
event.getTextChannel().sendMessage("Shut up eyyyy du kek").queue();
|
|
||||||
} else {
|
|
||||||
AudioTrack track = new AudioManager().getPlayer(event.getGuild()).getPlayingTrack();
|
AudioTrack track = new AudioManager().getPlayer(event.getGuild()).getPlayingTrack();
|
||||||
event.getTextChannel().sendMessage("Track Info" + String.format(QUEUE_DESCRIPTION, CD, new AudioManager().getOrNull(track.getInfo().title),
|
event.getTextChannel().sendMessage("Track Info" + String.format(QUEUE_DESCRIPTION, CD, new AudioManager().getOrNull(track.getInfo().title),
|
||||||
"\n\u23F1 **|>** `[ " + getTimestamp(track.getPosition()) + " / " + getTimestamp(track.getInfo().length) + " ]`",
|
"\n\u23F1 **|>** `[ " + new AudioManager().getTimestamp(track.getPosition()) + " / " + new AudioManager().getTimestamp(track.getInfo().length) + " ]`",
|
||||||
"\n" + MIC, new AudioManager().getOrNull(track.getInfo().author),
|
"\n" + MIC, new AudioManager().getOrNull(track.getInfo().author),
|
||||||
"\n\uD83C\uDFA7 **|>** " + "")).queue();
|
"\n\uD83C\uDFA7 **|>** " + "")).queue();
|
||||||
|
} else {
|
||||||
|
event.getTextChannel().sendMessage(event.getMessageEditor().getMessage(MessageEditor.MessageType.ERROR,
|
||||||
|
"commands.music.info.error.title",
|
||||||
|
"commands.music.info.error.description").build()).queue();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getTimestamp(long milis) {
|
|
||||||
long seconds = milis / 1000;
|
|
||||||
long hours = Math.floorDiv(seconds, 3600);
|
|
||||||
seconds = seconds - (hours * 3600);
|
|
||||||
long mins = Math.floorDiv(seconds, 60);
|
|
||||||
seconds = seconds - (mins * 60);
|
|
||||||
return (hours == 0 ? "" : hours + ":") + String.format("%02d", mins) + ":" + String.format("%02d", seconds);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String[] labels() {
|
public String[] labels() {
|
||||||
return new String[]{"info"};
|
return new String[]{"info", "songinfo"};
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -15,14 +15,14 @@ public class LeaveCommand implements Command {
|
||||||
if (event.getGuild().getSelfMember().getVoiceState().inVoiceChannel()) {
|
if (event.getGuild().getSelfMember().getVoiceState().inVoiceChannel()) {
|
||||||
event.getGuild().getAudioManager().closeAudioConnection();
|
event.getGuild().getAudioManager().closeAudioConnection();
|
||||||
event.getTextChannel().sendMessage(event.getMessageEditor().getMessage(
|
event.getTextChannel().sendMessage(event.getMessageEditor().getMessage(
|
||||||
MessageEditor.MessageType.INFO,
|
MessageEditor.MessageType.INFO,
|
||||||
"commands.music.leave.success.title",
|
"commands.music.leave.success.title",
|
||||||
"commands.music.leave.success.description")
|
"commands.music.leave.success.description")
|
||||||
.build()).queue();
|
.build()).queue();
|
||||||
} else {
|
} else {
|
||||||
event.getTextChannel().sendMessage(event.getMessageEditor().getMessage(
|
event.getTextChannel().sendMessage(event.getMessageEditor().getMessage(
|
||||||
MessageEditor.MessageType.WARNING,
|
MessageEditor.MessageType.WARNING,
|
||||||
"commands.music.leave.error.tile",
|
"commands.music.leave.error.tile",
|
||||||
"commands.music.leave.error.description")
|
"commands.music.leave.error.description")
|
||||||
.build()).queue();
|
.build()).queue();
|
||||||
}
|
}
|
||||||
|
|
@ -30,7 +30,7 @@ public class LeaveCommand implements Command {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String[] labels() {
|
public String[] labels() {
|
||||||
return new String[]{"leave"};
|
return new String[]{"leave", "quit"};
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ public class StopCommand implements Command {
|
||||||
@Override
|
@Override
|
||||||
public void executed(String[] args, CommandEvent event) {
|
public void executed(String[] args, CommandEvent event) {
|
||||||
if (new AudioManager().hasPlayer(event.getGuild())) {
|
if (new AudioManager().hasPlayer(event.getGuild())) {
|
||||||
AudioManager.removePlayer(event.getGuild());
|
new AudioManager().players.remove(event.getGuild().getId());
|
||||||
new AudioManager().getPlayer(event.getGuild()).destroy();
|
new AudioManager().getPlayer(event.getGuild()).destroy();
|
||||||
new AudioManager().getTrackManager(event.getGuild()).purgeQueue();
|
new AudioManager().getTrackManager(event.getGuild()).purgeQueue();
|
||||||
event.getGuild().getAudioManager().closeAudioConnection();
|
event.getGuild().getAudioManager().closeAudioConnection();
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ package com.bbn.hadder.commands.owner;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import com.bbn.hadder.Hadder;
|
import com.bbn.hadder.Hadder;
|
||||||
|
import com.bbn.hadder.audio.AudioManager;
|
||||||
import com.bbn.hadder.commands.Command;
|
import com.bbn.hadder.commands.Command;
|
||||||
import com.bbn.hadder.commands.CommandEvent;
|
import com.bbn.hadder.commands.CommandEvent;
|
||||||
import com.bbn.hadder.core.Perm;
|
import com.bbn.hadder.core.Perm;
|
||||||
|
|
@ -43,6 +44,7 @@ public class EvalCommand implements Command {
|
||||||
engine.put("author", event.getAuthor());
|
engine.put("author", event.getAuthor());
|
||||||
engine.put("member", event.getMember());
|
engine.put("member", event.getMember());
|
||||||
engine.put("self", event.getGuild().getSelfMember());
|
engine.put("self", event.getGuild().getSelfMember());
|
||||||
|
engine.put("audio", new AudioManager());
|
||||||
|
|
||||||
ScheduledExecutorService service = Executors.newScheduledThreadPool(1);
|
ScheduledExecutorService service = Executors.newScheduledThreadPool(1);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -84,7 +84,7 @@ commands.misc.screenshare.channel.existing.error = Hol' up
|
||||||
commands.misc.screenshare.channel.existing.description = There is no Voice Channel named like this. \n\nNote\: Make sure the Voice Channel is in this Guild.
|
commands.misc.screenshare.channel.existing.description = There is no Voice Channel named like this. \n\nNote\: Make sure the Voice Channel is in this Guild.
|
||||||
commands.misc.screenshare.help.description = Shows you the link to share your screen.
|
commands.misc.screenshare.help.description = Shows you the link to share your screen.
|
||||||
|
|
||||||
commands.moderation.ban.success.title = %extra% Successfully banned %extra%
|
commands.moderation.ban.success.title = Successfully banned
|
||||||
commands.moderation.ban.success.description = I successfully baned %extra%
|
commands.moderation.ban.success.description = I successfully baned %extra%
|
||||||
commands.moderation.ban.error.title = Not possible
|
commands.moderation.ban.error.title = Not possible
|
||||||
commands.moderation.ban.myself.error.description = I can not ban myself\!
|
commands.moderation.ban.myself.error.description = I can not ban myself\!
|
||||||
|
|
@ -203,6 +203,8 @@ commands.music.play.success.length = Length
|
||||||
commands.music.play.help.description = Plays a song
|
commands.music.play.help.description = Plays a song
|
||||||
commands.music.stop.success.title = Successfully stopped
|
commands.music.stop.success.title = Successfully stopped
|
||||||
commands.music.stop.success.description = I successfully stopped the song.
|
commands.music.stop.success.description = I successfully stopped the song.
|
||||||
|
commands.music.info.error.title = No playing track
|
||||||
|
commands.music.info.error.description = I am not playing anything at the moment
|
||||||
commands.music.stop.help.description = Stops the song
|
commands.music.stop.help.description = Stops the song
|
||||||
commands.music.queue.error.title = No queue
|
commands.music.queue.error.title = No queue
|
||||||
commands.music.queue.error.description = There are no queued songs at the moment
|
commands.music.queue.error.description = There are no queued songs at the moment
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue