Search in sources :

Example 1 with NewsChannel

use of net.dv8tion.jda.api.entities.NewsChannel in project JavaBot by Java-Discord.

the class CancelSubcommand method handleJamCommand.

@Override
protected ReplyCallbackAction handleJamCommand(SlashCommandInteractionEvent event, Jam activeJam, Connection con, JamConfig config) throws SQLException {
    OptionMapping confirmOption = event.getOption("confirm");
    if (confirmOption == null || !confirmOption.getAsString().equals("yes")) {
        return Responses.warning(event, "Invalid confirmation. Type `yes` to confirm cancellation.");
    }
    NewsChannel announcementChannel = config.getAnnouncementChannel();
    if (announcementChannel == null)
        throw new IllegalArgumentException("Invalid jam announcement channel id.");
    new JamRepository(con).cancelJam(activeJam);
    announcementChannel.sendMessage("The current Java Jam has been cancelled.").queue();
    return Responses.success(event, "Jam Cancelled", "The " + activeJam.getFullName() + " has been cancelled.");
}
Also used : OptionMapping(net.dv8tion.jda.api.interactions.commands.OptionMapping) NewsChannel(net.dv8tion.jda.api.entities.NewsChannel) JamRepository(net.javadiscord.javabot.systems.jam.dao.JamRepository)

Aggregations

NewsChannel (net.dv8tion.jda.api.entities.NewsChannel)1 OptionMapping (net.dv8tion.jda.api.interactions.commands.OptionMapping)1 JamRepository (net.javadiscord.javabot.systems.jam.dao.JamRepository)1