fix tmdb command errors
All checks were successful
Deploy to Dokku / docker (ubuntu-latest) (push) Successful in 39s
All checks were successful
Deploy to Dokku / docker (ubuntu-latest) (push) Successful in 39s
This commit is contained in:
parent
dc7e44239f
commit
a9e4626dfd
@ -44,10 +44,8 @@ public class TMDBFeature extends Feature {
|
||||
*/
|
||||
public static EmbedBuilder pageMovie(@NonNull TMDBService tmdbService, @NonNull String query, String language, String primaryReleaseYear, String region, String year, int movie, boolean adult) {
|
||||
List<Movie> movieList = tmdbService.lookupMovies(query, adult, language, primaryReleaseYear, region, year);
|
||||
|
||||
if (movieList == null || movieList.isEmpty()) {
|
||||
return EmbedUtils.errorEmbed()
|
||||
.setDescription("No movieList found with the provided query + options!");
|
||||
return null;
|
||||
}
|
||||
|
||||
// Adjust movie index to stay within bounds
|
||||
@ -79,10 +77,8 @@ public class TMDBFeature extends Feature {
|
||||
*/
|
||||
public static EmbedBuilder pageSeries(@NonNull TMDBService tmdbService, @NonNull String query, String language, int firstAirDateYear, int year, int series, boolean adult) {
|
||||
List<TvSeries> seriesList = tmdbService.lookupSeries(query, adult, language, firstAirDateYear, year);
|
||||
|
||||
if (seriesList == null || seriesList.isEmpty()) {
|
||||
return EmbedUtils.errorEmbed()
|
||||
.setDescription("No series found with the provided query + options!");
|
||||
return null;
|
||||
}
|
||||
|
||||
// Adjust series index to stay within bounds
|
||||
|
@ -9,6 +9,7 @@ import cc.fascinated.bat.model.BatGuild;
|
||||
import cc.fascinated.bat.model.BatUser;
|
||||
import cc.fascinated.bat.service.TMDBService;
|
||||
import lombok.NonNull;
|
||||
import net.dv8tion.jda.api.EmbedBuilder;
|
||||
import net.dv8tion.jda.api.entities.Member;
|
||||
import net.dv8tion.jda.api.entities.channel.concrete.TextChannel;
|
||||
import net.dv8tion.jda.api.entities.channel.middleman.MessageChannel;
|
||||
@ -76,17 +77,26 @@ public class MovieSubCommand extends BatSubCommand implements EventListener {
|
||||
|
||||
userCommands.put(user.getId(), params);
|
||||
|
||||
event.replyEmbeds(TMDBFeature.pageMovie(
|
||||
tmdbService,
|
||||
titleOption.getAsString(),
|
||||
(languageOption != null ? languageOption.getAsString() : null),
|
||||
(primaryReleaseYearOption != null ? primaryReleaseYearOption.getAsString() : null),
|
||||
(regionOption != null ? regionOption.getAsString() : null),
|
||||
(yearOption != null ? yearOption.getAsString() : null),
|
||||
0, // Initial page number
|
||||
adult
|
||||
).build()
|
||||
).addActionRow(
|
||||
EmbedBuilder embedBuilder = TMDBFeature.pageMovie(
|
||||
tmdbService,
|
||||
titleOption.getAsString(),
|
||||
(languageOption != null ? languageOption.getAsString() : null),
|
||||
(primaryReleaseYearOption != null ? primaryReleaseYearOption.getAsString() : null),
|
||||
(regionOption != null ? regionOption.getAsString() : null),
|
||||
(yearOption != null ? yearOption.getAsString() : null),
|
||||
0, // Initial page number
|
||||
adult
|
||||
);
|
||||
|
||||
if (embedBuilder == null) {
|
||||
event.replyEmbeds(EmbedUtils.errorEmbed()
|
||||
.setDescription("No movies found with the given parameters!")
|
||||
.build())
|
||||
.queue();
|
||||
return;
|
||||
}
|
||||
|
||||
event.replyEmbeds(embedBuilder.build()).addActionRow(
|
||||
Button.primary("backMovie", "Back").withEmoji(Emoji.fromFormatted("⬅️")),
|
||||
Button.primary("nextMovie", "Next").withEmoji(Emoji.fromFormatted("➡️"))
|
||||
).queue();
|
||||
@ -120,7 +130,7 @@ public class MovieSubCommand extends BatSubCommand implements EventListener {
|
||||
|
||||
params.put("page", String.valueOf(currentPage));
|
||||
|
||||
event.editMessageEmbeds(TMDBFeature.pageMovie(
|
||||
EmbedBuilder embedBuilder = TMDBFeature.pageMovie(
|
||||
tmdbService,
|
||||
title,
|
||||
language,
|
||||
@ -129,6 +139,14 @@ public class MovieSubCommand extends BatSubCommand implements EventListener {
|
||||
year,
|
||||
currentPage,
|
||||
adult
|
||||
).build()).queue();
|
||||
);
|
||||
if (embedBuilder == null) {
|
||||
event.replyEmbeds(EmbedUtils.errorEmbed()
|
||||
.setDescription("No movies found with the given parameters!")
|
||||
.build())
|
||||
.queue();
|
||||
return;
|
||||
}
|
||||
event.editMessageEmbeds(embedBuilder.build()).queue();
|
||||
}
|
||||
}
|
@ -9,6 +9,7 @@ import cc.fascinated.bat.model.BatGuild;
|
||||
import cc.fascinated.bat.model.BatUser;
|
||||
import cc.fascinated.bat.service.TMDBService;
|
||||
import lombok.NonNull;
|
||||
import net.dv8tion.jda.api.EmbedBuilder;
|
||||
import net.dv8tion.jda.api.entities.Member;
|
||||
import net.dv8tion.jda.api.entities.channel.concrete.TextChannel;
|
||||
import net.dv8tion.jda.api.entities.channel.middleman.MessageChannel;
|
||||
@ -71,17 +72,26 @@ public class SeriesSubCommand extends BatSubCommand implements EventListener {
|
||||
if (yearOption != null) params.put("year", String.valueOf(yearOption.getAsInt()));
|
||||
params.put("adult", String.valueOf(adult));
|
||||
|
||||
userCommands.put(user.getId(), params);
|
||||
EmbedBuilder embedBuilder = TMDBFeature.pageSeries(
|
||||
tmdbService,
|
||||
titleOption.getAsString(),
|
||||
(languageOption != null ? languageOption.getAsString() : null),
|
||||
(firstAirYearOption != null ? firstAirYearOption.getAsInt() : -1),
|
||||
(yearOption != null ? yearOption.getAsInt() : -1),
|
||||
0, // Initial page number
|
||||
adult
|
||||
);
|
||||
|
||||
event.replyEmbeds(TMDBFeature.pageSeries(
|
||||
tmdbService,
|
||||
titleOption.getAsString(),
|
||||
(languageOption != null ? languageOption.getAsString() : null),
|
||||
(firstAirYearOption != null ? firstAirYearOption.getAsInt() : -1),
|
||||
(yearOption != null ? yearOption.getAsInt() : -1),
|
||||
0, // Initial page number
|
||||
adult
|
||||
).build()
|
||||
if (embedBuilder == null) {
|
||||
event.replyEmbeds(EmbedUtils.errorEmbed()
|
||||
.setDescription("No series found with the given parameters!")
|
||||
.build())
|
||||
.queue();
|
||||
return;
|
||||
}
|
||||
|
||||
userCommands.put(user.getId(), params);
|
||||
event.replyEmbeds(embedBuilder.build()
|
||||
).addActionRow(
|
||||
Button.primary("backSeries", "Back").withEmoji(Emoji.fromFormatted("⬅️")),
|
||||
Button.primary("nextSeries", "Next").withEmoji(Emoji.fromFormatted("➡️"))
|
||||
@ -115,7 +125,7 @@ public class SeriesSubCommand extends BatSubCommand implements EventListener {
|
||||
|
||||
params.put("page", String.valueOf(currentPage));
|
||||
|
||||
event.editMessageEmbeds(TMDBFeature.pageSeries(
|
||||
EmbedBuilder embedBuilder = TMDBFeature.pageSeries(
|
||||
tmdbService,
|
||||
title,
|
||||
language,
|
||||
@ -123,6 +133,14 @@ public class SeriesSubCommand extends BatSubCommand implements EventListener {
|
||||
year,
|
||||
currentPage,
|
||||
adult
|
||||
).build()).queue();
|
||||
);
|
||||
if (embedBuilder == null) {
|
||||
event.editMessageEmbeds(EmbedUtils.errorEmbed()
|
||||
.setDescription("No series found with the given parameters!")
|
||||
.build())
|
||||
.queue();
|
||||
return;
|
||||
}
|
||||
event.editMessageEmbeds(embedBuilder.build()).queue();
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user