|
|
|
@ -295,10 +295,7 @@ public class GuildMusicHandler {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void upload(GuildMessageReceivedEvent event) {
|
|
|
|
|
if (!event.getMessage().getMember().hasPermission(Permission.ADMINISTRATOR, Permission.MANAGE_SERVER)) {
|
|
|
|
|
event.getChannel().sendMessage(String.format("Sorry <@%s> i can't do that. *psst: you have to have manage server, or administrator role*", event.getMember().getIdLong())).queue();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
isAdmin(event);
|
|
|
|
|
|
|
|
|
|
for(Attachment attachment : event.getMessage().getAttachments()) {
|
|
|
|
|
attachment.retrieveInputStream().thenAccept((in) -> {
|
|
|
|
@ -361,20 +358,17 @@ public class GuildMusicHandler {
|
|
|
|
|
sb.append("```");
|
|
|
|
|
event.getChannel().sendMessage(sb.toString()).queue();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void adminPlaylist(GuildMessageReceivedEvent event, List<String> commands) {
|
|
|
|
|
if(!isAdmin(event)) return;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void delete(GuildMessageReceivedEvent event, List<String> commands) {
|
|
|
|
|
if (!event.getMessage().getMember().hasPermission(Permission.ADMINISTRATOR, Permission.MANAGE_SERVER)) {
|
|
|
|
|
event.getChannel().sendMessage(String.format("Sorry <@%s> i can't do that. *psst: you have to have manage server, or administrator role*", event.getMember().getIdLong())).queue();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if(!isAdmin(event)) return;
|
|
|
|
|
|
|
|
|
|
if (commands == null || commands.isEmpty()) {
|
|
|
|
|
event.getChannel().sendMessage(event.getAuthor().getAsMention() + " please provide the name of the playlist to play").queue();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (commands == null || commands.isEmpty()) {
|
|
|
|
|
event.getChannel().sendMessage("Missing command for +delete. Valid commands are: song, playlist").queue();
|
|
|
|
|
event.getChannel().sendMessage(event.getMember().getAsMention() + ", Missing command for +delete. Valid commandis : +delete song uuids...").queue();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -384,9 +378,6 @@ public class GuildMusicHandler {
|
|
|
|
|
case "song":
|
|
|
|
|
deleteSong(event, commands);
|
|
|
|
|
return;
|
|
|
|
|
case "playlist":
|
|
|
|
|
deleteUserPlayList(event, commands);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -591,10 +582,8 @@ public class GuildMusicHandler {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void deleteSong(GuildMessageReceivedEvent event, List<String> commands) {
|
|
|
|
|
if (commands == null || commands.isEmpty()) {
|
|
|
|
|
event.getChannel().sendMessage(event.getAuthor().getAsMention() + ", you have to provide the list of uuids for songs to remove").queue();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if(!checkCommands(event, commands,
|
|
|
|
|
event.getAuthor().getAsMention() + ", you have to provide the list of uuids for songs to remove")) return;
|
|
|
|
|
|
|
|
|
|
List<GuildSong> songs = guildSongRepoService.getGuildSongRepo().findByGuildAndUuidIn(event.getGuild().getIdLong(), commands.stream().collect(Collectors.toSet()));
|
|
|
|
|
if (songs.isEmpty()) {
|
|
|
|
@ -629,7 +618,7 @@ public class GuildMusicHandler {
|
|
|
|
|
|
|
|
|
|
private void deleteUserPlayList(GuildMessageReceivedEvent event, List<String> commands) {
|
|
|
|
|
// TODO Auto-generated method stub
|
|
|
|
|
|
|
|
|
|
System.out.println(commands.stream().collect(Collectors.joining(", ")));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void deleteGuildSongsConfirm(List<GuildSong> songs, String user, Message msg) {
|
|
|
|
@ -646,10 +635,8 @@ public class GuildMusicHandler {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void deletePlayList(GuildMessageReceivedEvent event, List<String> commands) {
|
|
|
|
|
if (commands == null || commands.isEmpty()) {
|
|
|
|
|
event.getChannel().sendMessage(event.getAuthor().getAsMention() + " you have to provide the playlist to create a new playlist (no spaces in name) and optionally a list of uuids for songs to add").queue();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if(!checkCommands(event, commands,
|
|
|
|
|
event.getAuthor().getAsMention() + " you have to provide the playlist name and optionally a list of uuids for songs to remove")) return;
|
|
|
|
|
|
|
|
|
|
Long guildId = event.getGuild().getIdLong();
|
|
|
|
|
|
|
|
|
@ -743,10 +730,8 @@ public class GuildMusicHandler {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void addPlayList(GuildMessageReceivedEvent event, List<String> commands) {
|
|
|
|
|
if (commands == null || commands.isEmpty()) {
|
|
|
|
|
event.getChannel().sendMessage(event.getAuthor().getAsMention() + " you have to provide the playlist to create a new playlist (no spaces in name) and optionally a list of uuids for songs to add").queue();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if(!checkCommands(event, commands,
|
|
|
|
|
event.getAuthor().getAsMention() + " you have to provide the playlist to create a new playlist (no spaces in name) and optionally a list of uuids for songs to add")) return;
|
|
|
|
|
|
|
|
|
|
Long guildId = event.getGuild().getIdLong();
|
|
|
|
|
|
|
|
|
@ -850,6 +835,22 @@ public class GuildMusicHandler {
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private boolean isAdmin(GuildMessageReceivedEvent event) {
|
|
|
|
|
if (!event.getMessage().getMember().hasPermission(Permission.ADMINISTRATOR, Permission.MANAGE_SERVER)) {
|
|
|
|
|
event.getChannel().sendMessage(String.format("Sorry <@%s> i can't do that. *psst: you have to have manage server, or administrator role*", event.getMember().getIdLong())).queue();
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private boolean checkCommands(GuildMessageReceivedEvent event, List<String> commands, String msg) {
|
|
|
|
|
if (commands == null || commands.isEmpty()) {
|
|
|
|
|
event.getChannel().sendMessage(msg).queue();
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void deleteMessage(Message msg) {
|
|
|
|
|
try {
|
|
|
|
@ -859,4 +860,5 @@ public class GuildMusicHandler {
|
|
|
|
|
if (ex.getErrorResponse() != ErrorResponse.UNKNOWN_MESSAGE) throw ex;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|