use of main.utils.json.dedicatedchannel.DedicatedChannelConfig in project Robertify-Bot by bombies.
the class AudioLoader method sendTrackLoadedMessage.
private void sendTrackLoadedMessage(AudioTrack audioTrack) {
EmbedBuilder eb = RobertifyEmbedUtils.embedMessage(guild, "Added to queue: `" + audioTrack.getInfo().title + "` by `" + audioTrack.getInfo().author + "`");
if (botMsg != null) {
if (LofiCommand.getLofiEnabledGuilds().contains(guild.getIdLong()) && LofiCommand.getAnnounceLofiMode().contains(guild.getIdLong())) {
LofiCommand.getAnnounceLofiMode().remove(guild.getIdLong());
botMsg.editMessageEmbeds(RobertifyEmbedUtils.embedMessage(guild, "You have enabled Lo-Fi mode").build()).queue();
} else {
botMsg.editMessageEmbeds(eb.build()).queue(success -> success.editMessageComponents().queue());
}
} else {
if (new DedicatedChannelConfig().isChannelSet(guild.getIdLong()))
new DedicatedChannelConfig().getTextChannel(guild.getIdLong()).sendMessageEmbeds(eb.build()).queue();
}
}
use of main.utils.json.dedicatedchannel.DedicatedChannelConfig in project Robertify-Bot by bombies.
the class AudioLoader method trackLoaded.
@Override
public void trackLoaded(AudioTrack audioTrack) {
sendTrackLoadedMessage(audioTrack);
if (!announceMsg)
RobertifyAudioManager.getUnannouncedTracks().add(audioTrack.getIdentifier());
trackRequestedByUser.putIfAbsent(guild.getIdLong(), new ArrayList<>());
trackRequestedByUser.get(guild.getIdLong()).add(sender.getId() + ":" + audioTrack.getIdentifier());
final var scheduler = musicManager.getScheduler();
scheduler.setAnnouncementChannel(announcementChannel);
if (addToBeginning)
scheduler.addToBeginningOfQueue(audioTrack);
else
scheduler.queue(audioTrack);
AudioTrackInfo info = audioTrack.getInfo();
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);
}
use of main.utils.json.dedicatedchannel.DedicatedChannelConfig in project Robertify-Bot by bombies.
the class RemoveCommand method handleRemove.
public EmbedBuilder handleRemove(Guild guild, User remover, ConcurrentLinkedQueue<AudioTrack> queue, int id) {
GeneralUtils.setCustomEmbed(guild, "Queue");
final List<AudioTrack> trackList = new ArrayList<>(queue);
if (queue.isEmpty()) {
EmbedBuilder eb = RobertifyEmbedUtils.embedMessage(guild, "There is nothing in the queue.");
return eb;
}
if (id <= 0 || id > queue.size())
return RobertifyEmbedUtils.embedMessage(guild, "This is an invalid ID! You must provide an ID between 1 and " + queue.size());
AudioTrack removedTrack = trackList.get(id - 1);
AudioTrackInfo info = removedTrack.getInfo();
EmbedBuilder eb = RobertifyEmbedUtils.embedMessage(guild, "Removed `" + info.title + "` from the queue");
if (!queue.remove(removedTrack))
eb = RobertifyEmbedUtils.embedMessage(guild, "Could not remove track with id " + id + " from the queue");
else
new LogUtils().sendLog(guild, LogType.QUEUE_REMOVE, remover.getAsMention() + " has removed `" + info.title + " by " + info.author + "` from the queue.");
if (id <= 10)
if (new DedicatedChannelConfig().isChannelSet(guild.getIdLong()))
new DedicatedChannelConfig().updateMessage(guild);
return eb;
}
use of main.utils.json.dedicatedchannel.DedicatedChannelConfig in project Robertify-Bot by bombies.
the class ClearQueueCommand method handle.
@Override
public void handle(CommandContext ctx) throws ScriptException {
final var musicManager = RobertifyAudioManager.getInstance().getMusicManager(ctx.getGuild());
final var queue = musicManager.getScheduler().queue;
final Message msg = ctx.getMessage();
final Guild guild = ctx.getGuild();
final GuildVoiceState selfVoiceState = ctx.getGuild().getSelfMember().getVoiceState();
GeneralUtils.setCustomEmbed(guild, "Queue");
if (queue.isEmpty()) {
EmbedBuilder eb = RobertifyEmbedUtils.embedMessage(guild, "There is already nothing in the queue.");
msg.replyEmbeds(eb.build()).queue();
return;
}
if (selfVoiceState.inVoiceChannel()) {
if (selfVoiceState.getChannel().getMembers().size() > 2) {
if (!GeneralUtils.hasPerms(ctx.getGuild(), ctx.getMember(), Permission.ROBERTIFY_DJ)) {
EmbedBuilder eb = RobertifyEmbedUtils.embedMessage(guild, "You need to be a DJ to use this command when there's other users in the channel!");
msg.replyEmbeds(eb.build()).queue();
return;
}
}
} else {
EmbedBuilder eb = RobertifyEmbedUtils.embedMessage(guild, "The bot isn't in a voice channel.");
msg.replyEmbeds(eb.build()).queue();
return;
}
queue.clear();
new LogUtils().sendLog(guild, LogType.QUEUE_CLEAR, ctx.getAuthor().getAsMention() + " has cleared the queue");
if (new DedicatedChannelConfig().isChannelSet(guild.getIdLong()))
new DedicatedChannelConfig().updateMessage(guild);
EmbedBuilder eb = RobertifyEmbedUtils.embedMessage(guild, "The queue was cleared!");
msg.replyEmbeds(eb.build()).queue();
GeneralUtils.setDefaultEmbed(guild);
}
use of main.utils.json.dedicatedchannel.DedicatedChannelConfig in project Robertify-Bot by bombies.
the class SetChannelCommand method handle.
@Override
public void handle(CommandContext ctx) throws ScriptException {
if (!GeneralUtils.hasPerms(ctx.getGuild(), ctx.getMember(), Permission.ROBERTIFY_ADMIN))
return;
final List<String> args = ctx.getArgs();
final Message msg = ctx.getMessage();
final Guild guild = ctx.getGuild();
var guildConfig = new GuildConfig();
if (args.isEmpty()) {
TextChannel channel = ctx.getChannel();
if (new DedicatedChannelConfig().isChannelSet(guild.getIdLong()))
if (channel.getIdLong() == new DedicatedChannelConfig().getChannelID(guild.getIdLong())) {
msg.replyEmbeds(RobertifyEmbedUtils.embedMessage(guild, "The announcement channel cannot be set to this channel!").build()).queue();
return;
}
if (guildConfig.getAnnouncementChannelID(guild.getIdLong()) == channel.getIdLong()) {
EmbedBuilder eb = RobertifyEmbedUtils.embedMessage(guild, "This is already the announcement channel.");
msg.replyEmbeds(eb.build()).queue();
} else {
guildConfig.setAnnouncementChannelID(guild.getIdLong(), channel.getIdLong());
EmbedBuilder eb = RobertifyEmbedUtils.embedMessage(guild, "Set the announcement channel to: " + channel.getAsMention());
msg.replyEmbeds(eb.build()).queue();
}
} else {
String id = GeneralUtils.getDigitsOnly(args.get(0));
if (!GeneralUtils.stringIsID(id)) {
EmbedBuilder eb = RobertifyEmbedUtils.embedMessage(guild, "ID provided isn't a valid ID!\n" + "Make sure to either **mention** the channel, or provide its **ID**").setImage("https://i.imgur.com/Qg0BQ3f.png");
msg.replyEmbeds(eb.build()).queue();
return;
}
TextChannel channel = Robertify.shardManager.getGuildById(guild.getIdLong()).getTextChannelById(id);
if (channel == null) {
EmbedBuilder eb = RobertifyEmbedUtils.embedMessage(guild, "That ID doesn't belong to any channel in this guild!");
msg.replyEmbeds(eb.build()).queue();
return;
}
if (new DedicatedChannelConfig().isChannelSet(guild.getIdLong()))
if (channel.getIdLong() == new DedicatedChannelConfig().getChannelID(guild.getIdLong())) {
msg.replyEmbeds(RobertifyEmbedUtils.embedMessage(guild, "The announcement channel cannot be set to that channel!").build()).queue();
return;
}
guildConfig.setAnnouncementChannelID(guild.getIdLong(), channel.getIdLong());
EmbedBuilder eb = RobertifyEmbedUtils.embedMessage(guild, "You've set the announcement channel to: " + channel.getAsMention());
msg.replyEmbeds(eb.build()).queue();
}
}
Aggregations