Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package me.legitzx.bot.mclisteners;
- import me.legitzx.bot.Info;
- import net.dv8tion.jda.core.entities.TextChannel;
- import net.dv8tion.jda.core.events.message.guild.GuildMessageReceivedEvent;
- import net.dv8tion.jda.core.hooks.ListenerAdapter;
- import java.io.*;
- import java.io.File;
- import java.io.IOException;
- public class BankListener extends ListenerAdapter {
- public static String str;
- public static int counter = 0;
- public String fileName = "C:\\Users\\Luciano\\Desktop\\Programming\\JAVA ROOT\\ClientsDiscordBots\\AbzyaBot\\consoleclient\\Console\\deposit.txt";
- public void onGuildMessageReceived(GuildMessageReceivedEvent event) {
- String[] args = event.getMessage().getContentRaw().split(" ");
- if (event.getMessage().getAuthor().isBot()) return;
- if (args[0].equalsIgnoreCase(Info.PREFIX + "setup")) {
- //readTextFileUsingScanner(fileName, event.getGuild().getTextChannelById("497238046031216651"));
- try {
- File file = new File(fileName);
- System.out.println(file.getAbsolutePath());
- if (file.exists() && file.canRead()) {
- long fileLength = file.length();
- readFile(file, 0L, event.getChannel());
- while (true) {
- if (fileLength < file.length()) {
- readFile(file, fileLength, event.getChannel());
- fileLength = file.length();
- }
- }
- }
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- }
- public static void readFile(File file, Long fileLength, TextChannel channel) throws IOException {
- String line = null;
- BufferedReader in = new BufferedReader(new java.io.FileReader(file));
- in.skip(fileLength);
- while ((line = in.readLine()) != null) {
- System.out.println(line);
- channel.sendMessage("`" + line + "`").queue();
- }
- in.close();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment