forked from MagicBane/Server
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
52 lines
1.7 KiB
52 lines
1.7 KiB
3 years ago
|
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
|
||
|
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
|
||
|
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
|
||
|
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
|
||
|
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
|
||
|
// Magicbane Emulator Project © 2013 - 2022
|
||
|
// www.magicbane.com
|
||
|
|
||
|
package discord.handlers;
|
||
|
|
||
|
import discord.MagicBot;
|
||
|
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||
|
import org.pmw.tinylog.Logger;
|
||
|
|
||
|
import java.io.IOException;
|
||
|
import java.nio.file.Files;
|
||
|
import java.nio.file.Paths;
|
||
|
|
||
|
public class FlashHandler {
|
||
|
|
||
|
public static void handleRequest(MessageReceivedEvent event, String[] args) {
|
||
|
|
||
|
String flashText;
|
||
|
|
||
|
// Early exit if database unavailable or is not an admin
|
||
|
|
||
|
if (MagicBot.isAdminEvent(event) == false)
|
||
|
return;
|
||
|
|
||
|
// Nothing to send?
|
||
|
|
||
|
if (args.length == 0)
|
||
|
return;
|
||
|
|
||
|
// Convert argument array into string;
|
||
|
|
||
|
flashText = String.join(" ", args);
|
||
|
|
||
|
// Write string to flash file.
|
||
|
|
||
|
try {
|
||
|
Files.write(Paths.get("flash"), flashText.getBytes());
|
||
|
} catch (IOException e) {
|
||
|
Logger.error(e.toString());
|
||
|
}
|
||
|
|
||
|
Logger.info(event.getAuthor().getName() + " sent flash: " + flashText);
|
||
|
MagicBot.sendResponse(event, "Flash: " + flashText);
|
||
|
|
||
|
}
|
||
|
}
|