Search in sources :

Example 16 with TextChannel

use of net.dv8tion.jda.core.entities.TextChannel in project Gary by help-chat.

the class WordChanger method run.

public void run() {
    TextChannel channel = jda.getTextChannelById(Constants.CR);
    String word = crr.getRandomWord();
    String scrambled = crr.scrambleWord(word);
    MessageEmbed message = new EmbedBuilder().setTitle("Word Update").setDescription(mutil.bigLetters(scrambled)).setFooter("Gary v" + version.getVersion(), "https://cdn.discordapp.com/avatars/332142935380459520/2d2b0a78ec3ab461f23721a51a292a3e.png").build();
    channel.getManager().setTopic("Scramble >> " + mutil.bigLetters(scrambled)).queue();
    channel.sendMessage(message).complete().delete().queueAfter(5, TimeUnit.MINUTES);
    files.setWord(word);
}
Also used : TextChannel(net.dv8tion.jda.core.entities.TextChannel) EmbedBuilder(net.dv8tion.jda.core.EmbedBuilder) MessageEmbed(net.dv8tion.jda.core.entities.MessageEmbed)

Example 17 with TextChannel

use of net.dv8tion.jda.core.entities.TextChannel in project pokeraidbot by magnusmickelsson.

the class StartUpEventListener method attachToGroupMessage.

private boolean attachToGroupMessage(Guild guild, Config config, RaidGroup raidGroup) {
    MessageChannel channel = null;
    try {
        final List<TextChannel> textChannels = guild.getTextChannels();
        for (TextChannel textChannel : textChannels) {
            if (textChannel.getName().equalsIgnoreCase(raidGroup.getChannel())) {
                channel = textChannel;
                break;
            }
        }
        final Locale locale = config.getLocale();
        Raid raid = raidRepository.getById(raidGroup.getRaidId());
        final EmoticonSignUpMessageListener emoticonSignUpMessageListener = new EmoticonSignUpMessageListener(botService, localeService, serverConfigRepository, raidRepository, pokemonRepository, gymRepository, raid.getId(), raidGroup.getStartsAt(), raidGroup.getCreatorId());
        emoticonSignUpMessageListener.setEmoteMessageId(raidGroup.getEmoteMessageId());
        emoticonSignUpMessageListener.setInfoMessageId(raidGroup.getInfoMessageId());
        final int delayTime = raid.isExRaid() ? 1 : 15;
        final TimeUnit delayTimeUnit = raid.isExRaid() ? TimeUnit.MINUTES : TimeUnit.SECONDS;
        final Callable<Boolean> groupEditTask = NewRaidGroupCommand.getMessageRefreshingTaskToSchedule(channel, raid, emoticonSignUpMessageListener, raidGroup.getInfoMessageId(), locale, raidRepository, localeService, clockService, executorService, botService, delayTimeUnit, delayTime, raidGroup.getId());
        executorService.submit(groupEditTask);
        if (LOGGER.isDebugEnabled()) {
            LOGGER.debug("Found group message for raid " + raid + " in channel " + (channel == null ? "N/A" : channel.getName()) + " (server " + guild.getName() + "). Attaching to it.");
        }
        return true;
    } catch (UserMessedUpException e) {
        if (channel != null)
            channel.sendMessage(e.getMessage()).queue(m -> {
                m.delete().queueAfter(BotServerMain.timeToRemoveFeedbackInSeconds, TimeUnit.SECONDS);
            });
    } catch (ErrorResponseException e) {
        // We couldn't find the message in this channel or had permission issues, ignore
        LOGGER.info("Caught exception during startup: " + e.getMessage());
        LOGGER.warn("Cleaning up raidgroup...");
        cleanUpRaidGroup(raidGroup);
        LOGGER.debug("Stacktrace:", e);
    } catch (Throwable e) {
        LOGGER.warn("Cleaning up raidgroup due to exception: " + e.getMessage());
        cleanUpRaidGroup(raidGroup);
    }
    return false;
}
Also used : Locale(java.util.Locale) Raid(pokeraidbot.domain.raid.Raid) TextChannel(net.dv8tion.jda.core.entities.TextChannel) MessageChannel(net.dv8tion.jda.core.entities.MessageChannel) EmoticonSignUpMessageListener(pokeraidbot.domain.raid.signup.EmoticonSignUpMessageListener) TimeUnit(java.util.concurrent.TimeUnit) UserMessedUpException(pokeraidbot.domain.errors.UserMessedUpException) ErrorResponseException(net.dv8tion.jda.core.exceptions.ErrorResponseException)

Example 18 with TextChannel

use of net.dv8tion.jda.core.entities.TextChannel in project Ardent by adamint.

the class TriviaGame method finish.

public void finish(Shard shard, Command command) throws Exception {
    totalRounds = 9001;
    final int bonus = 250;
    final int perQuestion = 50;
    Trivia.gamesInSession.remove(this);
    Trivia.gamesSettingUp.remove(guildId);
    Guild guild = shard.jda.getGuildById(guildId);
    TextChannel channel = guild.getTextChannelById(textChannelId);
    channel.sendMessage(displayScores(shard, command).build()).queue();
    channel.sendMessage("Thanks for playing! You'll receive **$50** for every correct answer").queue();
    Map<String, Integer> sorted = MapUtils.sortByValue(scores);
    Iterator<Map.Entry<String, Integer>> iterator = sorted.entrySet().iterator();
    int current = 0;
    while (iterator.hasNext()) {
        Map.Entry<String, Integer> entry = iterator.next();
        User user = guild.getMemberById(entry.getKey()).getUser();
        Profile profile = Profile.get(user);
        profile.addMoney(perQuestion * entry.getValue());
        if (current == 0 && !isSolo() && scores.size() > 1) {
            profile.addMoney(bonus);
            channel.sendMessage(user.getAsMention() + ", you won a **$250** bonus for being so smart!").queue();
        }
        current++;
    }
}
Also used : TextChannel(net.dv8tion.jda.core.entities.TextChannel) User(net.dv8tion.jda.core.entities.User) Guild(net.dv8tion.jda.core.entities.Guild) HashMap(java.util.HashMap) Map(java.util.Map) Profile(tk.ardentbot.utils.rpg.profiles.Profile)

Example 19 with TextChannel

use of net.dv8tion.jda.core.entities.TextChannel in project Ardent by adamint.

the class ArdentMusicManager method setChannel.

public void setChannel(MessageChannel channel) {
    assert channel != null;
    this.channel = channel.getId();
    MusicSettingsModel guildMusicSettings = BaseCommand.asPojo(r.db("data").table("music_settings").get(((TextChannel) channel).getGuild().getId()).run(connection), MusicSettingsModel.class);
    shouldAnnounce = !(guildMusicSettings == null || !guildMusicSettings.announce_music);
}
Also used : TextChannel(net.dv8tion.jda.core.entities.TextChannel) MusicSettingsModel(tk.ardentbot.rethink.models.MusicSettingsModel)

Example 20 with TextChannel

use of net.dv8tion.jda.core.entities.TextChannel in project TheLighterBot by PhotonBursted.

the class FileController method retrieveLinkedChannels.

private void retrieveLinkedChannels() throws SQLException {
    retrieveData("SELECT *\n" + "FROM \"LinkedChannels\"", result -> {
        try {
            TextChannel tc = l.getBot().getTextChannelById(result.getLong("tc_id"));
            VoiceChannel vc = l.getBot().getVoiceChannelById(result.getLong("vc_id"));
            if (tc != null && vc != null) {
                l.getChannelController().getLinkedChannels().putStoring(tc, vc);
            }
        } catch (SQLException ex) {
            log.error("Something went wrong retrieving the linked channels", ex);
        }
    });
}
Also used : TextChannel(net.dv8tion.jda.core.entities.TextChannel) VoiceChannel(net.dv8tion.jda.core.entities.VoiceChannel)

Aggregations

TextChannel (net.dv8tion.jda.core.entities.TextChannel)91 EmbedBuilder (net.dv8tion.jda.core.EmbedBuilder)27 Guild (net.dv8tion.jda.core.entities.Guild)22 User (net.dv8tion.jda.core.entities.User)20 Member (net.dv8tion.jda.core.entities.Member)18 List (java.util.List)17 Message (net.dv8tion.jda.core.entities.Message)17 ArrayList (java.util.ArrayList)14 VoiceChannel (net.dv8tion.jda.core.entities.VoiceChannel)13 GuildWrapper (stream.flarebot.flarebot.objects.GuildWrapper)13 MessageUtils (stream.flarebot.flarebot.util.MessageUtils)13 Collectors (java.util.stream.Collectors)11 CommandType (stream.flarebot.flarebot.commands.CommandType)8 Role (net.dv8tion.jda.core.entities.Role)7 FlareBot (stream.flarebot.flarebot.FlareBot)7 Track (com.arsenarsen.lavaplayerbridge.player.Track)6 MessageEmbed (net.dv8tion.jda.core.entities.MessageEmbed)6 MantaroData (net.kodehawa.mantarobot.data.MantaroData)6 DBGuild (net.kodehawa.mantarobot.db.entities.DBGuild)6 EmoteReference (net.kodehawa.mantarobot.utils.commands.EmoteReference)6