Improve currency validation by using java.util.Currency
Remove unused commands Update dependencies
This commit is contained in:
1 parent
64dd0da604
commit
b5b0e209c7
8 files changed
+23
-246
No files matched your search
@@ -102,7 +102,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-assembly-plugin</artifactId>
|
<artifactId>maven-assembly-plugin</artifactId>
|
||||||
<version>3.3.0</version>
|
<version>3.4.2</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
@@ -118,7 +118,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.github.walkyst</groupId>
|
<groupId>com.github.walkyst</groupId>
|
||||||
<artifactId>lavaplayer-fork</artifactId>
|
<artifactId>lavaplayer-fork</artifactId>
|
||||||
<version>1.3.98.3</version>
|
<version>1.3.98.4</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
@@ -140,7 +140,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>io.sentry</groupId>
|
<groupId>io.sentry</groupId>
|
||||||
<artifactId>sentry</artifactId>
|
<artifactId>sentry</artifactId>
|
||||||
<version>6.0.0</version>
|
<version>6.4.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>p6spy</groupId>
|
<groupId>p6spy</groupId>
|
||||||
@@ -164,17 +164,17 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>mysql</groupId>
|
<groupId>mysql</groupId>
|
||||||
<artifactId>mysql-connector-java</artifactId>
|
<artifactId>mysql-connector-java</artifactId>
|
||||||
<version>8.0.29</version>
|
<version>8.0.30</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.logging.log4j</groupId>
|
<groupId>org.apache.logging.log4j</groupId>
|
||||||
<artifactId>log4j-core</artifactId>
|
<artifactId>log4j-core</artifactId>
|
||||||
<version>2.17.2</version>
|
<version>2.18.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.logging.log4j</groupId>
|
<groupId>org.apache.logging.log4j</groupId>
|
||||||
<artifactId>log4j-slf4j-impl</artifactId>
|
<artifactId>log4j-slf4j-impl</artifactId>
|
||||||
<version>2.17.2</version>
|
<version>2.18.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ import org.json.JSONException;
|
|||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
|
||||||
import java.text.NumberFormat;
|
import java.text.NumberFormat;
|
||||||
|
import java.util.Currency;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
public class BitcoinPriceCommand extends AbstractCommand {
|
public class BitcoinPriceCommand extends AbstractCommand {
|
||||||
@@ -66,13 +67,12 @@ public class BitcoinPriceCommand extends AbstractCommand {
|
|||||||
String currency = "USD";
|
String currency = "USD";
|
||||||
|
|
||||||
if (args.length == 1) {
|
if (args.length == 1) {
|
||||||
if (Currency.isCurrency(args[0].toUpperCase()))
|
try {
|
||||||
currency = args[0].toUpperCase();
|
currency = Currency.getInstance(args[0].toUpperCase()).getCurrencyCode();
|
||||||
else {
|
} catch (IllegalArgumentException exception) {
|
||||||
context.reply("Please enter a valid currency");
|
context.reply("Please enter a valid currency");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
String finalCurrency = currency;
|
String finalCurrency = currency;
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ import org.json.JSONException;
|
|||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
|
||||||
import java.text.NumberFormat;
|
import java.text.NumberFormat;
|
||||||
|
import java.util.Currency;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
public class CryptoPriceCommand extends AbstractCommand {
|
public class CryptoPriceCommand extends AbstractCommand {
|
||||||
@@ -52,7 +53,7 @@ public class CryptoPriceCommand extends AbstractCommand {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getDescription() {
|
public String getDescription() {
|
||||||
return "Get the price of cryptocurrrency";
|
return "Get the price of cryptocurrencies";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -66,15 +67,13 @@ public class CryptoPriceCommand extends AbstractCommand {
|
|||||||
String currency = "USD";
|
String currency = "USD";
|
||||||
|
|
||||||
if (args.length > 0) {
|
if (args.length > 0) {
|
||||||
|
|
||||||
if (args.length == 2) {
|
if (args.length == 2) {
|
||||||
if (Currency.isCurrency(args[1].toUpperCase()))
|
try {
|
||||||
currency = args[1].toUpperCase();
|
currency = Currency.getInstance(args[1].toUpperCase()).getCurrencyCode();
|
||||||
else {
|
} catch (IllegalArgumentException exception) {
|
||||||
context.reply("Please enter a valid currency");
|
context.reply("Please enter a valid currency");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
String crypto = args[0].toUpperCase();
|
String crypto = args[0].toUpperCase();
|
||||||
|
|||||||
@@ -1,52 +0,0 @@
|
|||||||
package netneutrality.command.crypto;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright (c) anthorob
|
|
||||||
*
|
|
||||||
* https://xtremcommunity.com/
|
|
||||||
* https://discord.gg/CdFcyQ
|
|
||||||
*/
|
|
||||||
public enum Currency {
|
|
||||||
|
|
||||||
AED("AED"), AFN("AFN"), ALL("ALL"), AMD("AMD"), ANG("ANG"), AOA("AOA"), ARS("ARS"), AUD("AUD"), AWG("AWG"), AZN("AZN"), BAM("BAM"), BBD("BBD"),
|
|
||||||
BDT("BDT"), BGN("BGN"), BHD("BHD"), BIF("BIF"), BMD("BMD"), BND("BND"), BOB("BOB"), BOV("BOV"), BRL("BRL"), BSD("BSD"), BTN("BTN"), BWP("BWP"),
|
|
||||||
BYN("BYN"), BYR("BYR"), BZD("BZD"), CAD("CAD"), CDF("CDF"), CHE("CHE"), CHF("CHF"), CHW("CHW"), CLF("CLF"), CLP("CLP"), CNY("CNY"), COP("COP"),
|
|
||||||
COU("COU"), CRC("CRC"), CUC("CUC"), CUP("CUP"), CVE("CVE"), CZK("CZK"), DJF("DJF"), DKK("DKK"), DOP("DOP"), DZD("DZD"), EGP("EGP"), ERN("ERN"),
|
|
||||||
ETB("ETB"), EUR("EUR"), FJD("FJD"), FKP("FKP"), GBP("GBP"), GEL("GEL"), GHS("GHS"), GIP("GIP"), GMD("GMD"), GNF("GNF"), GTQ("GTQ"), GYD("GYD"),
|
|
||||||
HKD("HKD"), HNL("HNL"), HRK("HRK"), HTG("HTG"), HUF("HUF"), IDR("IDR"), ILS("ILS"), INR("INR"), IQD("IQD"), IRR("IRR"), ISK("ISK"), JMD("JMD"),
|
|
||||||
JOD("JOD"), JPY("JPY"), KES("KES"), KGS("KGS"), KHR("KHR"), KMF("KMF"), KPW("KPW"), KRW("KRW"), KWD("KWD"), KYD("KYD"), KZT("KZT"), LAK("LAK"),
|
|
||||||
LBP("LBP"), LKR("LKR"), LRD("LRD"), LSL("LSL"), LYD("LYD"), MAD("MAD"), MDL("MDL"), MGA("MGA"), MKD("MKD"), MMK("MMK"), MNT("MNT"), MOP("MOP"),
|
|
||||||
MRO("MRO"), MUR("MUR"), MVR("MVR"), MWK("MWK"), MXN("MXN"), MXV("MXV"), MYR("MYR"), MZN("MZN"), NAD("NAD"), NGN("NGN"), NIO("NIO"), NOK("NOK"),
|
|
||||||
NPR("NPR"), NZD("NZD"), OMR("OMR"), PAB("PAB"), PEN("PEN"), PGK("PGK"), PHP("PHP"), PKR("PKR"), PLN("PLN"), PYG("PYG"), QAR("QAR"), RON("RON"),
|
|
||||||
RSD("RSD"), RUB("RUB"), RWF("RWF"), SAR("SAR"), SBD("SBD"), SCR("SCR"), SDG("SDG"), SEK("SEK"), SGD("SGD"), SHP("SHP"), SLL("SLL"), SOS("SOS"),
|
|
||||||
SRD("SRD"), SSP("SSP"), STD("STD"), SYP("SYP"), SZL("SZL"), THB("THB"), TJS("TJS"), TMT("TMT"), TND("TND"), TOP("TOP"), TRY("TRY"), TTD("TTD"),
|
|
||||||
TWD("TWD"), TZS("TZS"), UAH("UAH"), UGX("UGX"), USD("USD"), USN("USN"), UYI("UYI"), UYU("UYU"), UZS("UZS"), VEF("VEF"), VND("VND"), VUV("VUV"),
|
|
||||||
WST("WST"), XAF("XAF"), XAG("XAG"), XAU("XAU"), XBA("XBA"), XBB("XBB"), XBC("XBC"), XBD("XBD"), XCD("XCD"), XDR("XDR"), XFU("XFU"), XOF("XOF"),
|
|
||||||
XPD("XPD"), XPF("XPF"), XPT("XPT"), XSU("XSU"), XTS("XTS"), XUA("XUA"), XXX("XXX"), YER("YER"), ZAR("ZAR"), ZMW("ZMW");
|
|
||||||
|
|
||||||
private final String iso4217Code;
|
|
||||||
|
|
||||||
Currency(String code) {
|
|
||||||
this.iso4217Code = code;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getIso4217Code() {
|
|
||||||
return iso4217Code;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return "Currency{" +
|
|
||||||
"iso4217Code='" + iso4217Code + '\'' +
|
|
||||||
'}';
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean isCurrency(String str) {
|
|
||||||
for (Currency c : Currency.values()) {
|
|
||||||
if (c.name().equals(str.toUpperCase()))
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -16,6 +16,7 @@ import org.json.JSONException;
|
|||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
|
||||||
import java.text.NumberFormat;
|
import java.text.NumberFormat;
|
||||||
|
import java.util.Currency;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
public class EthereumPriceCommand extends AbstractCommand {
|
public class EthereumPriceCommand extends AbstractCommand {
|
||||||
@@ -66,13 +67,12 @@ public class EthereumPriceCommand extends AbstractCommand {
|
|||||||
String currency = "USD";
|
String currency = "USD";
|
||||||
|
|
||||||
if (args.length == 1) {
|
if (args.length == 1) {
|
||||||
if (Currency.isCurrency(args[0].toUpperCase()))
|
try {
|
||||||
currency = args[0].toUpperCase();
|
currency = Currency.getInstance(args[0].toUpperCase()).getCurrencyCode();
|
||||||
else {
|
} catch (IllegalArgumentException exception) {
|
||||||
context.reply("Please enter a valid currency");
|
context.reply("Please enter a valid currency");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
String finalCurrency = currency;
|
String finalCurrency = currency;
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ import org.json.JSONException;
|
|||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
|
||||||
import java.text.NumberFormat;
|
import java.text.NumberFormat;
|
||||||
|
import java.util.Currency;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
public class LitecoinPriceCommand extends AbstractCommand {
|
public class LitecoinPriceCommand extends AbstractCommand {
|
||||||
@@ -66,13 +67,12 @@ public class LitecoinPriceCommand extends AbstractCommand {
|
|||||||
String currency = "USD";
|
String currency = "USD";
|
||||||
|
|
||||||
if (args.length == 1) {
|
if (args.length == 1) {
|
||||||
if (Currency.isCurrency(args[0].toUpperCase()))
|
try {
|
||||||
currency = args[0].toUpperCase();
|
currency = Currency.getInstance(args[0].toUpperCase()).getCurrencyCode();
|
||||||
else {
|
} catch (IllegalArgumentException exception) {
|
||||||
context.reply("Please enter a valid currency");
|
context.reply("Please enter a valid currency");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
String finalCurrency = currency;
|
String finalCurrency = currency;
|
||||||
|
|||||||
@@ -1,115 +0,0 @@
|
|||||||
package netneutrality.command.specific;
|
|
||||||
/*
|
|
||||||
* Copyright (c) anthorob
|
|
||||||
*
|
|
||||||
* https://xtremcommunity.com/
|
|
||||||
* https://discord.gg/CdFcyQ
|
|
||||||
*/
|
|
||||||
|
|
||||||
import net.dv8tion.jda.api.EmbedBuilder;
|
|
||||||
import net.dv8tion.jda.api.entities.User;
|
|
||||||
import netneutrality.command.AbstractCommand;
|
|
||||||
import netneutrality.command.CommandType;
|
|
||||||
import netneutrality.command.CommandUsage;
|
|
||||||
import netneutrality.core.context.CommandContext;
|
|
||||||
import netneutrality.db.DBController;
|
|
||||||
import netneutrality.db.controllers.DBMessage;
|
|
||||||
import netneutrality.db.entities.OLogMessage;
|
|
||||||
import netneutrality.utils.Settings;
|
|
||||||
|
|
||||||
import java.awt.*;
|
|
||||||
import java.time.OffsetDateTime;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class DatabaseCommand extends AbstractCommand {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean needAdmin() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isEnabled() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getCommandName() {
|
|
||||||
return "database";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String[] getAlias() {
|
|
||||||
return new String[]{"db"};
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public CommandUsage getUsage() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getDescription() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public CommandType getType() {
|
|
||||||
return CommandType.UNLISTED;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void execute(CommandContext context) {
|
|
||||||
//TODO: Clean up the mess
|
|
||||||
String[] args = context.getArgs();
|
|
||||||
context.getMessage().delete().queue();
|
|
||||||
|
|
||||||
if (!context.getGuildUser().getId().equals(Settings.getInstance().getCreatorId()))
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (args.length > 0) {
|
|
||||||
switch (args[0]) {
|
|
||||||
|
|
||||||
case "message":
|
|
||||||
|
|
||||||
if (args.length > 1) {
|
|
||||||
|
|
||||||
OLogMessage message = DBController.get(DBMessage.class).getMessage(args[1]);
|
|
||||||
if (message != null) {
|
|
||||||
EmbedBuilder embed = new EmbedBuilder();
|
|
||||||
embed.setColor(Color.BLUE);
|
|
||||||
embed.setTimestamp(message.getDateSent());
|
|
||||||
embed.setFooter("Guild : " + context.getGuild().getId() + " | ID : " + message.getMessageId(), null);
|
|
||||||
embed.setDescription(
|
|
||||||
"Message from " + message.getUserId() + " on the channel " + message.getChannelId());
|
|
||||||
embed.addField("Message: ", "" + message.getMessage(), false);
|
|
||||||
context.reply(embed.build());
|
|
||||||
} else {
|
|
||||||
//TODO: cached user lol xd
|
|
||||||
User user = context.getJDA().getUserById(args[1]);
|
|
||||||
if (user != null) {
|
|
||||||
List<OLogMessage> messages = DBController.get(DBMessage.class)
|
|
||||||
.getMessagesFromUser(user.getName(), context.getGuild().getName(), 10);
|
|
||||||
EmbedBuilder embed = new EmbedBuilder();
|
|
||||||
embed.setColor(Color.BLUE);
|
|
||||||
embed.setTimestamp(OffsetDateTime.now());
|
|
||||||
for (OLogMessage message1 : messages) {
|
|
||||||
embed.addField(
|
|
||||||
"Message in channel \"" + message1.getChannelId() + "\" sent on "
|
|
||||||
+ message1.getDateSent(),
|
|
||||||
"" + message1.getMessage(), false);
|
|
||||||
}
|
|
||||||
embed.setFooter("Guild : " + context.getGuild().getName(), null);
|
|
||||||
|
|
||||||
context.replyPrivate(embed.build());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,55 +0,0 @@
|
|||||||
package netneutrality.command.specific;
|
|
||||||
/*
|
|
||||||
* Copyright (c) anthorob
|
|
||||||
*
|
|
||||||
* https://xtremcommunity.com/
|
|
||||||
* https://discord.gg/CdFcyQ
|
|
||||||
*/
|
|
||||||
|
|
||||||
import netneutrality.command.AbstractCommand;
|
|
||||||
import netneutrality.command.CommandType;
|
|
||||||
import netneutrality.command.CommandUsage;
|
|
||||||
import netneutrality.core.context.CommandContext;
|
|
||||||
|
|
||||||
public class LoggingCommand extends AbstractCommand {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean needAdmin() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isEnabled() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getCommandName() {
|
|
||||||
return "logging";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String[] getAlias() {
|
|
||||||
return new String[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public CommandUsage getUsage() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getDescription() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public CommandType getType() {
|
|
||||||
return CommandType.UNLISTED;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void execute(CommandContext context) {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Reference in new issue
Block a user