mirror of
https://github.com/Noratrieb/killua-bot.git
synced 2026-01-14 23:25:01 +01:00
fight thing prototype no
This commit is contained in:
parent
504e63a9b9
commit
eabd310db6
5 changed files with 32 additions and 10 deletions
|
|
@ -13,7 +13,7 @@ public class Config {
|
||||||
public static final String NORMAL_PREFIX = "kil ";
|
public static final String NORMAL_PREFIX = "kil ";
|
||||||
public static final String L_PREFIX = "k ";
|
public static final String L_PREFIX = "k ";
|
||||||
|
|
||||||
public static final String PREFIX = NORMAL_PREFIX;
|
public static final String PREFIX = L_PREFIX;
|
||||||
|
|
||||||
public static final Color DEFAULT_COLOR = new Color(229, 201, 255);
|
public static final Color DEFAULT_COLOR = new Color(229, 201, 255);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +0,0 @@
|
||||||
package com.github.nilstrieb.cofig;
|
|
||||||
|
|
||||||
public class Secrets {
|
|
||||||
public static final String TOKEN = "invite the xp bot to your discord";
|
|
||||||
}
|
|
||||||
|
|
@ -0,0 +1,23 @@
|
||||||
|
package com.github.nilstrieb.commands.fun;
|
||||||
|
|
||||||
|
import com.github.nilstrieb.cofig.Config;
|
||||||
|
import com.github.nilstrieb.commands.handler.Command;
|
||||||
|
import net.dv8tion.jda.api.EmbedBuilder;
|
||||||
|
|
||||||
|
public class FightCommand extends Command {
|
||||||
|
|
||||||
|
private static String[] abilities = {"Little Flower", "Jajanken", "Lightning", "punch", "Chapter 7 Bankruptcy", "Ripper Cyclotron", "Rising Sun",
|
||||||
|
"100-Type Guanyin Bodhisattva"};
|
||||||
|
|
||||||
|
public FightCommand() {
|
||||||
|
super("fight", "Fight against someone else!", "fight Tonpa", "");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void called(String args) {
|
||||||
|
EmbedBuilder builder = Config.getDefaultEmbed();
|
||||||
|
String author = event.getAuthor().getAsTag();
|
||||||
|
builder.addField(author + " x " + args, "A fight breaks out between " + author + " and " + args, false);
|
||||||
|
reply(builder.build());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -36,6 +36,8 @@ public class EmoteAddCommand extends Command {
|
||||||
reply("No image attached");
|
reply("No image attached");
|
||||||
} else if (args.length() < 3) {
|
} else if (args.length() < 3) {
|
||||||
reply("Name must be at least 3 characters: " + args);
|
reply("Name must be at least 3 characters: " + args);
|
||||||
|
} else if (!args.matches("\\w+")) {
|
||||||
|
reply("Emote names are only allowed to contain characters, numbers and underscore");
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
Message.Attachment image = attachments.get(0);
|
Message.Attachment image = attachments.get(0);
|
||||||
|
|
@ -72,7 +74,8 @@ public class EmoteAddCommand extends Command {
|
||||||
private byte[] resizeImage(byte[] bytes, String format, int size) throws IOException {
|
private byte[] resizeImage(byte[] bytes, String format, int size) throws IOException {
|
||||||
reply("Image size too big (" + bytes.length / 1000 + "kB). Resizing image...");
|
reply("Image size too big (" + bytes.length / 1000 + "kB). Resizing image...");
|
||||||
Image image = ImageIO.read(new ByteArrayInputStream(bytes));
|
Image image = ImageIO.read(new ByteArrayInputStream(bytes));
|
||||||
image = image.getScaledInstance(size, size, Image.SCALE_SMOOTH);
|
int ratio = image.getHeight(null) / image.getWidth(null);
|
||||||
|
image = image.getScaledInstance(size, size * ratio, Image.SCALE_SMOOTH);
|
||||||
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||||
|
|
||||||
BufferedImage bufferedImg = new BufferedImage(image.getWidth(null), image.getHeight(null), BufferedImage.TYPE_INT_ARGB);
|
BufferedImage bufferedImg = new BufferedImage(image.getWidth(null), image.getHeight(null), BufferedImage.TYPE_INT_ARGB);
|
||||||
|
|
@ -82,7 +85,7 @@ public class EmoteAddCommand extends Command {
|
||||||
|
|
||||||
ImageIO.write(bufferedImg, format, out);
|
ImageIO.write(bufferedImg, format, out);
|
||||||
bytes = out.toByteArray();
|
bytes = out.toByteArray();
|
||||||
if(bytes.length > MAX_EMOTE_SIZE){
|
if (bytes.length > MAX_EMOTE_SIZE) {
|
||||||
return resizeImage(bytes, format, size - 100);
|
return resizeImage(bytes, format, size - 100);
|
||||||
} else {
|
} else {
|
||||||
return bytes;
|
return bytes;
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ import com.github.nilstrieb.cofig.Config;
|
||||||
import com.github.nilstrieb.cofig.Secrets;
|
import com.github.nilstrieb.cofig.Secrets;
|
||||||
//import com.github.nilstrieb.commands.fun.DepartureCommand;
|
//import com.github.nilstrieb.commands.fun.DepartureCommand;
|
||||||
import com.github.nilstrieb.commands.fun.DepartureCommand;
|
import com.github.nilstrieb.commands.fun.DepartureCommand;
|
||||||
|
import com.github.nilstrieb.commands.fun.FightCommand;
|
||||||
import com.github.nilstrieb.commands.fun.QuoteCommand;
|
import com.github.nilstrieb.commands.fun.QuoteCommand;
|
||||||
import com.github.nilstrieb.commands.fun.SayCommand;
|
import com.github.nilstrieb.commands.fun.SayCommand;
|
||||||
import com.github.nilstrieb.commands.fun.trivia.TriviaCommand;
|
import com.github.nilstrieb.commands.fun.trivia.TriviaCommand;
|
||||||
|
|
@ -16,7 +17,6 @@ import com.github.nilstrieb.listener.ChannelMessageListener;
|
||||||
import com.github.nilstrieb.listener.CommandListener;
|
import com.github.nilstrieb.listener.CommandListener;
|
||||||
import com.github.nilstrieb.listener.ReactionEventListener;
|
import com.github.nilstrieb.listener.ReactionEventListener;
|
||||||
import com.github.nilstrieb.listener.StartUpListener;
|
import com.github.nilstrieb.listener.StartUpListener;
|
||||||
import net.dv8tion.jda.api.EmbedBuilder;
|
|
||||||
import net.dv8tion.jda.api.JDA;
|
import net.dv8tion.jda.api.JDA;
|
||||||
import net.dv8tion.jda.api.JDABuilder;
|
import net.dv8tion.jda.api.JDABuilder;
|
||||||
import net.dv8tion.jda.api.entities.Activity;
|
import net.dv8tion.jda.api.entities.Activity;
|
||||||
|
|
@ -30,7 +30,7 @@ import java.util.Scanner;
|
||||||
public class Main {
|
public class Main {
|
||||||
|
|
||||||
public static void main(String[] args) throws LoginException {
|
public static void main(String[] args) throws LoginException {
|
||||||
JDABuilder builder = JDABuilder.createDefault(Secrets.TOKEN);
|
JDABuilder builder = JDABuilder.createDefault(Secrets.L_TOKEN);
|
||||||
builder.setCompression(Compression.ZLIB);
|
builder.setCompression(Compression.ZLIB);
|
||||||
builder.setActivity(Activity.watching("over Gon"));
|
builder.setActivity(Activity.watching("over Gon"));
|
||||||
|
|
||||||
|
|
@ -78,5 +78,6 @@ public class Main {
|
||||||
new DepartureCommand();
|
new DepartureCommand();
|
||||||
new TriviaCommand();
|
new TriviaCommand();
|
||||||
new EmoteAddCommand();
|
new EmoteAddCommand();
|
||||||
|
new FightCommand();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue