use of main.utils.json.logs.LogUtils in project Robertify-Bot by bombies.
the class KaraokeFilter method onSlashCommand.
@Override
public void onSlashCommand(@NotNull SlashCommandEvent event) {
if (!checksWithPremium(event))
return;
sendRandomMessage(event);
final var guild = event.getGuild();
final var musicManager = RobertifyAudioManager.getInstance().getMusicManager(guild);
final var audioPlayer = musicManager.getPlayer();
final var filters = audioPlayer.getFilters();
final var selfMember = guild.getSelfMember();
if (!selfMember.getVoiceState().inVoiceChannel()) {
event.replyEmbeds(RobertifyEmbedUtils.embedMessage(guild, "I must be in a voice channel in order for this command to work!").build()).setEphemeral(true).queue();
return;
}
GuildVoiceState memberVoiceState = event.getMember().getVoiceState();
if (!memberVoiceState.inVoiceChannel()) {
event.replyEmbeds(RobertifyEmbedUtils.embedMessage(guild, "You must be in the same voice channel as me to use this command").build()).setEphemeral(true).queue();
return;
}
if (!memberVoiceState.getChannel().equals(selfMember.getVoiceState().getChannel())) {
event.replyEmbeds(RobertifyEmbedUtils.embedMessage(guild, "You must be in the same voice channel as me to use this command").build()).setEphemeral(true).queue();
return;
}
if (filters.getKaraoke() != null) {
filters.setKaraoke(null).commit();
event.replyEmbeds(RobertifyEmbedUtils.embedMessage(guild, "You have turned **off** the **Karaoke** filter").build()).queue();
new LogUtils().sendLog(guild, LogType.FILTER_TOGGLE, event.getUser().getAsMention() + " has turned the Karaoke filter off");
} else {
filters.setKaraoke(new Karaoke()).commit();
event.replyEmbeds(RobertifyEmbedUtils.embedMessage(guild, "You have turned **on** the **Karaoke** filter").build()).queue();
new LogUtils().sendLog(guild, LogType.FILTER_TOGGLE, event.getUser().getAsMention() + " has turned the Karaoke filter ofn");
}
}
use of main.utils.json.logs.LogUtils in project Robertify-Bot by bombies.
the class NightcoreFilter method handle.
@Override
public void handle(CommandContext ctx) throws ScriptException {
final var guild = ctx.getGuild();
final var msg = ctx.getMessage();
final var musicManager = RobertifyAudioManager.getInstance().getMusicManager(guild);
final var audioPlayer = musicManager.getPlayer();
final var filters = audioPlayer.getFilters();
final var selfMember = ctx.getSelfMember();
if (!selfMember.getVoiceState().inVoiceChannel()) {
msg.replyEmbeds(RobertifyEmbedUtils.embedMessage(guild, "I must be in a voice channel in order for this command to work!").build()).queue();
return;
}
GuildVoiceState memberVoiceState = ctx.getMember().getVoiceState();
if (!memberVoiceState.inVoiceChannel()) {
msg.replyEmbeds(RobertifyEmbedUtils.embedMessage(guild, "You must be in the same voice channel as me to use this command").build()).queue();
return;
}
if (!memberVoiceState.getChannel().equals(selfMember.getVoiceState().getChannel())) {
msg.replyEmbeds(RobertifyEmbedUtils.embedMessage(guild, "You must be in the same voice channel as me to use this command").build()).queue();
return;
}
if (filters.getTimescale() != null) {
filters.setTimescale(null).commit();
msg.replyEmbeds(RobertifyEmbedUtils.embedMessage(guild, "You have turned **off** the **Nightcore** filter").build()).queue();
new LogUtils().sendLog(guild, LogType.FILTER_TOGGLE, ctx.getAuthor().getAsMention() + " has turned the Nightcore filter off");
} else {
filters.setTimescale(new Timescale().setPitch(1.5F)).commit();
msg.replyEmbeds(RobertifyEmbedUtils.embedMessage(guild, "You have turned **on** the **Nightcore** filter").build()).queue();
new LogUtils().sendLog(guild, LogType.FILTER_TOGGLE, ctx.getAuthor().getAsMention() + " has turned the Nightcore filter on");
}
}
use of main.utils.json.logs.LogUtils in project Robertify-Bot by bombies.
the class StopCommand method handleStop.
public EmbedBuilder handleStop(Member stopper) {
Guild guild = stopper.getGuild();
final var selfVoiceState = guild.getSelfMember().getVoiceState();
final var memberVoiceState = stopper.getVoiceState();
if (!selfVoiceState.inVoiceChannel())
return RobertifyEmbedUtils.embedMessage(guild, "There is nothing playing!");
if (!memberVoiceState.inVoiceChannel())
return RobertifyEmbedUtils.embedMessage(guild, "You need to be in a voice channel for this to work");
if (!memberVoiceState.getChannel().equals(selfVoiceState.getChannel()))
return RobertifyEmbedUtils.embedMessage(guild, "You must be in the same voice channel as me to use this command!" + "\n\nI am currently in: " + selfVoiceState.getChannel().getAsMention());
;
final var musicManager = RobertifyAudioManager.getInstance().getMusicManager(guild);
final var audioPlayer = musicManager.getPlayer();
final var scheduler = musicManager.getScheduler();
final AudioTrack track = audioPlayer.getPlayingTrack();
if (track == null)
return RobertifyEmbedUtils.embedMessage(guild, "There is nothing playing!");
scheduler.repeating = false;
scheduler.playlistRepeating = false;
audioPlayer.stopTrack();
scheduler.queue.clear();
scheduler.getPastQueue().clear();
if (audioPlayer.isPaused())
audioPlayer.setPaused(false);
if (new DedicatedChannelConfig().isChannelSet(guild.getIdLong()))
new DedicatedChannelConfig().updateMessage(guild);
LofiCommand.getLofiEnabledGuilds().remove(guild.getIdLong());
new LogUtils().sendLog(guild, LogType.PLAYER_STOP, stopper.getAsMention() + " has stopped the player");
scheduler.scheduleDisconnect(true);
return RobertifyEmbedUtils.embedMessage(guild, "You have stopped the track and cleared the queue.");
}
use of main.utils.json.logs.LogUtils in project Robertify-Bot by bombies.
the class LogCommand method onSlashCommand.
@Override
public void onSlashCommand(@NotNull SlashCommandEvent event) {
if (!checks(event))
return;
final Guild guild = event.getGuild();
try {
new LogUtils().createChannel(guild);
event.replyEmbeds(RobertifyEmbedUtils.embedMessage(guild, "Successfully created the log channel!").build()).queue();
} catch (IllegalArgumentException e) {
event.replyEmbeds(RobertifyEmbedUtils.embedMessage(guild, "The log channel has already been setup!").build()).queue();
}
}
use of main.utils.json.logs.LogUtils in project Robertify-Bot by bombies.
the class AudioLoader method playlistLoaded.
@Override
public void playlistLoaded(AudioPlaylist audioPlaylist) {
List<AudioTrack> tracks = audioPlaylist.getTracks();
if (audioPlaylist.isSearchResult()) {
sendTrackLoadedMessage(tracks.get(0));
if (!announceMsg)
RobertifyAudioManager.getUnannouncedTracks().add(tracks.get(0).getIdentifier());
if (sender != null) {
trackRequestedByUser.putIfAbsent(guild.getIdLong(), new ArrayList<>());
trackRequestedByUser.get(guild.getIdLong()).add(sender.getId() + ":" + tracks.get(0).getIdentifier());
}
final var scheduler = musicManager.getScheduler();
scheduler.setAnnouncementChannel(announcementChannel);
if (addToBeginning)
scheduler.addToBeginningOfQueue(tracks.get(0));
else
scheduler.queue(tracks.get(0));
AudioTrackInfo info = tracks.get(0).getInfo();
if (sender != null)
new LogUtils().sendLog(guild, LogType.QUEUE_ADD, sender.getAsMention() + " has added `" + info.title + " by " + info.author + "` to the queue.");
if (scheduler.playlistRepeating)
scheduler.setSavedQueue(guild, scheduler.queue);
if (new DedicatedChannelConfig().isChannelSet(guild.getIdLong()))
new DedicatedChannelConfig().updateMessage(guild);
} else {
EmbedBuilder eb = RobertifyEmbedUtils.embedMessage(guild, "Added to queue: `" + tracks.size() + "` tracks from `" + audioPlaylist.getName() + "`");
if (botMsg != null)
botMsg.editMessageEmbeds(eb.build()).queue();
else {
new DedicatedChannelConfig().getTextChannel(guild.getIdLong()).sendMessageEmbeds(eb.build()).queue();
}
if (!announceMsg)
for (final AudioTrack track : tracks) RobertifyAudioManager.getUnannouncedTracks().add(track.getIdentifier());
if (loadPlaylistShuffled)
Collections.shuffle(tracks);
final var scheduler = musicManager.getScheduler();
scheduler.setAnnouncementChannel(announcementChannel);
if (addToBeginning)
scheduler.addToBeginningOfQueue(tracks);
if (sender != null) {
trackRequestedByUser.putIfAbsent(guild.getIdLong(), new ArrayList<>());
new LogUtils().sendLog(guild, LogType.QUEUE_ADD, sender.getAsMention() + " has added `" + audioPlaylist.getTracks().size() + "` songs from playlist `" + audioPlaylist.getName() + "` to the queue.");
}
for (final AudioTrack track : tracks) {
if (sender != null)
trackRequestedByUser.get(guild.getIdLong()).add(sender.getId() + ":" + track.getIdentifier());
if (!addToBeginning)
scheduler.queue(track);
}
if (scheduler.playlistRepeating)
scheduler.setSavedQueue(guild, scheduler.queue);
if (new DedicatedChannelConfig().isChannelSet(guild.getIdLong()))
new DedicatedChannelConfig().updateMessage(guild);
}
}
Aggregations