use of main.utils.json.logs.LogUtils in project Robertify-Bot by bombies.
the class SeekCommand method handleSeek.
public EmbedBuilder handleSeek(GuildVoiceState selfVoiceState, GuildVoiceState memberVoiceState, int mins, int sec) {
final var guild = selfVoiceState.getGuild();
if (!selfVoiceState.inVoiceChannel())
return RobertifyEmbedUtils.embedMessage(guild, "I must be in a voice channel for this command to work");
if (!memberVoiceState.inVoiceChannel())
return RobertifyEmbedUtils.embedMessage(guild, "You must be in the same voice channel I am in order to use this command");
if (memberVoiceState.getChannel().getIdLong() != selfVoiceState.getChannel().getIdLong())
return RobertifyEmbedUtils.embedMessage(guild, "You must be in the same voice channel I am in order to use this command");
final var musicManager = RobertifyAudioManager.getInstance().getMusicManager(selfVoiceState.getGuild());
final var audioPlayer = musicManager.getPlayer();
if (audioPlayer.getPlayingTrack() == null)
return RobertifyEmbedUtils.embedMessage(guild, "There is nothing playing!");
if (mins < 0 || mins > 59)
return RobertifyEmbedUtils.embedMessage(guild, "You must provide a valid amount of minutes.");
if (sec < 0 || sec > 59)
return RobertifyEmbedUtils.embedMessage(guild, "You must provide a valid amount of seconds.");
long totalDurationInMillis = TimeUnit.MINUTES.toMillis(mins) + TimeUnit.SECONDS.toMillis(sec);
AudioTrackInfo info = audioPlayer.getPlayingTrack().getInfo();
if (totalDurationInMillis > info.length)
return RobertifyEmbedUtils.embedMessage(guild, "The position provided is greater than the length of the playing track");
audioPlayer.seekTo(totalDurationInMillis);
new LogUtils().sendLog(guild, LogType.TRACK_SEEK, memberVoiceState.getMember().getAsMention() + " has seeked `" + (mins > 9 ? mins : "0" + mins) + ":" + (sec > 9 ? sec : "0" + sec) + "` on `" + info.title + " by " + info.author + "`");
return RobertifyEmbedUtils.embedMessage(guild, "You have seeked `" + (mins > 9 ? mins : "0" + mins) + ":" + (sec > 9 ? sec : "0" + sec) + "`!");
}
use of main.utils.json.logs.LogUtils in project Robertify-Bot by bombies.
the class ShuffleCommand method handleShuffle.
public EmbedBuilder handleShuffle(Guild guild, User shuffler) {
final var musicManager = RobertifyAudioManager.getInstance().getMusicManager(guild);
final var queue = musicManager.getScheduler().queue;
if (queue.isEmpty())
return RobertifyEmbedUtils.embedMessage(guild, "There is nothing in the queue.");
final List<AudioTrack> trackList = new ArrayList<>(queue);
Collections.shuffle(trackList);
queue.clear();
queue.addAll(trackList);
if (new DedicatedChannelConfig().isChannelSet(guild.getIdLong()))
new DedicatedChannelConfig().updateMessage(guild);
new LogUtils().sendLog(guild, LogType.QUEUE_SHUFFLE, shuffler.getAsMention() + " has shuffled the queue");
return RobertifyEmbedUtils.embedMessage(guild, "Shuffled the queue!");
}
use of main.utils.json.logs.LogUtils in project Robertify-Bot by bombies.
the class SkipToCommand method handleSkip.
public EmbedBuilder handleSkip(User skipper, ConcurrentLinkedQueue<AudioTrack> queue, GuildMusicManager musicManager, int id) {
if (id > queue.size() || id <= 0)
return RobertifyEmbedUtils.embedMessage(musicManager.getGuild(), "ID provided isn't a valid ID!");
final var audioPlayer = musicManager.getPlayer();
final var scheduler = musicManager.getScheduler();
final var guild = musicManager.getGuild();
List<AudioTrack> currentQueue = new ArrayList<>(queue);
List<AudioTrack> songsToRemoveFromQueue = new ArrayList<>();
for (int i = 0; i < id - 1; i++) songsToRemoveFromQueue.add(currentQueue.get(i));
queue.removeAll(songsToRemoveFromQueue);
audioPlayer.seekTo(0);
HashMap<Long, Stack<AudioTrack>> pastQueue = scheduler.getPastQueue();
if (!pastQueue.containsKey(guild.getIdLong()))
pastQueue.put(guild.getIdLong(), new Stack<>());
AudioTrack playingTrack = audioPlayer.getPlayingTrack();
pastQueue.get(guild.getIdLong()).push(playingTrack);
try {
scheduler.nextTrack(playingTrack, true, playingTrack.getPosition());
} catch (AutoPlayException ignored) {
}
if (new DedicatedChannelConfig().isChannelSet(guild.getIdLong()))
new DedicatedChannelConfig().updateMessage(guild);
LofiCommand.getLofiEnabledGuilds().remove(guild.getIdLong());
new LogUtils().sendLog(guild, LogType.TRACK_SKIP, skipper.getAsMention() + " has skipped to `track #" + id + "`");
SkipCommand.clearVoteSkipInfo(guild);
return RobertifyEmbedUtils.embedMessage(musicManager.getGuild(), "Skipped to **track #" + id + "**!");
}
use of main.utils.json.logs.LogUtils in project Robertify-Bot by bombies.
the class VolumeCommand method handleVolumeChange.
public EmbedBuilder handleVolumeChange(GuildVoiceState selfVoiceState, GuildVoiceState memberVoiceState, int volume) {
final var guild = selfVoiceState.getGuild();
if (!selfVoiceState.inVoiceChannel())
return RobertifyEmbedUtils.embedMessage(guild, "You can't use this command while I'm not in a voice channel");
if (memberVoiceState.inVoiceChannel() && !memberVoiceState.getChannel().equals(selfVoiceState.getChannel()))
return RobertifyEmbedUtils.embedMessage(guild, "You must be in the same voice channel as I am to use this command");
if (volume < 0 || volume > 100)
return RobertifyEmbedUtils.embedMessage(guild, "You can't set the volume to that value");
var musicManager = RobertifyAudioManager.getInstance().getMusicManager(memberVoiceState.getGuild());
var audioPlayer = musicManager.getPlayer();
audioPlayer.getFilters().setVolume((float) volume / 100).commit();
if (new DedicatedChannelConfig().isChannelSet(selfVoiceState.getGuild().getIdLong()))
new DedicatedChannelConfig().updateMessage(selfVoiceState.getGuild());
new LogUtils().sendLog(guild, LogType.VOLUME_CHANGE, memberVoiceState.getMember().getAsMention() + " has changed the volume to `" + volume + "%`");
return RobertifyEmbedUtils.embedMessage(guild, "🔊 You have set the volume of the bot to **" + volume + "%**");
}
use of main.utils.json.logs.LogUtils in project Robertify-Bot by bombies.
the class DisconnectCommand method handleDisconnect.
public EmbedBuilder handleDisconnect(Guild guild, User disconnecter) {
var musicManager = RobertifyAudioManager.getInstance().getMusicManager(guild);
musicManager.leave();
new LogUtils().sendLog(guild, LogType.BOT_DISCONNECTED, disconnecter.getAsMention() + " has disconnected the bot.");
return RobertifyEmbedUtils.embedMessage(guild, "Disconnected!");
}
Aggregations