Improve final fields naming
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
d62d6bdfdd
commit
94037b252f
@ -24,7 +24,7 @@ public class Cache
|
|||||||
|
|
||||||
|
|
||||||
// todo: make this compatible with the message listener's regex
|
// todo: make this compatible with the message listener's regex
|
||||||
private static final String botPrefix = "hideko";
|
private static final String BOT_PREFIX = "hideko";
|
||||||
private static final Logger LOGGER = LoggerFactory.getLogger(Cache.class);
|
private static final Logger LOGGER = LoggerFactory.getLogger(Cache.class);
|
||||||
|
|
||||||
// map to store results of "love calculator", to avoid people re-running the same command until
|
// map to store results of "love calculator", to avoid people re-running the same command until
|
||||||
@ -38,11 +38,11 @@ public class Cache
|
|||||||
private static DatabaseSource databaseSource = null;
|
private static DatabaseSource databaseSource = null;
|
||||||
private static boolean verbose = false;
|
private static boolean verbose = false;
|
||||||
private static MessageLogger verbosityLogger = null;
|
private static MessageLogger verbosityLogger = null;
|
||||||
private static final long botMaintainerId = 979809420714332260L;
|
private static final long BOT_MAINTAINER_ID = 979809420714332260L;
|
||||||
private static final String expiryTimestampFormat = "yy/MM/dd HH:mm:ss";
|
private static final String EXPIRY_TIMESTAMP_FORMAT = "yy/MM/dd HH:mm:ss";
|
||||||
|
|
||||||
// note: discord sets interactions' expiry time to 15 minutes by default, so we can't go higher than that.
|
// note: discord sets interactions' expiry time to 15 minutes by default, so we can't go higher than that.
|
||||||
private static final long expiryTimeSeconds = 30L;
|
private static final long EXPIRY_TIME_SECONDS = 30L;
|
||||||
|
|
||||||
// used to count e.g. uptime
|
// used to count e.g. uptime
|
||||||
private static LocalDateTime startupTime = null;
|
private static LocalDateTime startupTime = null;
|
||||||
@ -53,14 +53,14 @@ public class Cache
|
|||||||
// the scheduler that should always be used when running a scheduled task.
|
// the scheduler that should always be used when running a scheduled task.
|
||||||
private static final ScheduledExecutorService taskScheduler = Executors.newSingleThreadScheduledExecutor(); // todo: try-with-resources
|
private static final ScheduledExecutorService taskScheduler = Executors.newSingleThreadScheduledExecutor(); // todo: try-with-resources
|
||||||
|
|
||||||
private static final String execPath = System.getProperty("user.dir");
|
private static final String EXEC_PATH = System.getProperty("user.dir");
|
||||||
private static final String botName = "Hideko";
|
private static final String BOT_NAME = "Hideko";
|
||||||
|
|
||||||
private static SlashCommandListener slashCommandListener = null;
|
private static SlashCommandListener slashCommandListener = null;
|
||||||
private static SlashCommandCompletionListener slashCommandCompletionListener = null;
|
private static SlashCommandCompletionListener slashCommandCompletionListener = null;
|
||||||
private static MessageCommandListener messageCommandListener = null;
|
private static MessageCommandListener messageCommandListener = null;
|
||||||
|
|
||||||
private static final String defaultInviteLink =
|
private static final String DEFAULT_INVITE_LINK =
|
||||||
"https://discord.com/api/oauth2/authorize?client_id=%userid%&scope=bot+applications.commands&permissions=8";
|
"https://discord.com/api/oauth2/authorize?client_id=%userid%&scope=bot+applications.commands&permissions=8";
|
||||||
|
|
||||||
private static String botApplicationId = "";
|
private static String botApplicationId = "";
|
||||||
@ -137,7 +137,7 @@ public class Cache
|
|||||||
* @return a long of the account's id
|
* @return a long of the account's id
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public static long getBotMaintainerId() { return botMaintainerId; }
|
public static long getBotMaintainerId() { return BOT_MAINTAINER_ID; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the bot's application id.
|
* Set the bot's application id.
|
||||||
@ -162,7 +162,7 @@ public class Cache
|
|||||||
* @return a string containing the invite link
|
* @return a string containing the invite link
|
||||||
*/
|
*/
|
||||||
public static String getInviteUrl() {
|
public static String getInviteUrl() {
|
||||||
return defaultInviteLink.replace("%userid%", botApplicationId);
|
return DEFAULT_INVITE_LINK.replace("%userid%", botApplicationId);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -197,17 +197,17 @@ public class Cache
|
|||||||
*
|
*
|
||||||
* @return the String of the DateTimeFormatter format.
|
* @return the String of the DateTimeFormatter format.
|
||||||
*/
|
*/
|
||||||
public static String getExpiryTimestampFormat(){ return expiryTimestampFormat; }
|
public static String getExpiryTimestampFormat(){ return EXPIRY_TIMESTAMP_FORMAT; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the amount of seconds after which a message expires.
|
* Get the amount of seconds after which a message expires.
|
||||||
*
|
*
|
||||||
* @return long value of the expiry seconds.
|
* @return long value of the expiry seconds.
|
||||||
*/
|
*/
|
||||||
public static long getExpiryTimeSeconds() { return expiryTimeSeconds; }
|
public static long getExpiryTimeSeconds() { return EXPIRY_TIME_SECONDS; }
|
||||||
|
|
||||||
|
|
||||||
public static String getBotName() { return botName; }
|
public static String getBotName() { return BOT_NAME; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the bot's version.
|
* Get the bot's version.
|
||||||
@ -294,7 +294,7 @@ public class Cache
|
|||||||
return configurationSource == null ? null : (String) configurationSource.getConfigValue(ConfigurationEntry.HEARTBEAT_LINK);
|
return configurationSource == null ? null : (String) configurationSource.getConfigValue(ConfigurationEntry.HEARTBEAT_LINK);
|
||||||
}
|
}
|
||||||
//todo javadocs
|
//todo javadocs
|
||||||
public static String getExecPath() { return execPath; }
|
public static String getExecPath() { return EXEC_PATH; }
|
||||||
|
|
||||||
/*private static ConfigurationSource getConfigurationSource()
|
/*private static ConfigurationSource getConfigurationSource()
|
||||||
{ return configurationSource; }*/
|
{ return configurationSource; }*/
|
||||||
@ -311,7 +311,7 @@ public class Cache
|
|||||||
*
|
*
|
||||||
* @return a String of the bot's prefix.
|
* @return a String of the bot's prefix.
|
||||||
*/
|
*/
|
||||||
public static String getBotPrefix() { return botPrefix; }
|
public static String getBotPrefix() { return BOT_PREFIX; }
|
||||||
|
|
||||||
public static void cacheLoveCalculatorValue(String userId1, String userId2, int value)
|
public static void cacheLoveCalculatorValue(String userId1, String userId2, int value)
|
||||||
{
|
{
|
||||||
|
@ -36,8 +36,8 @@ import java.util.concurrent.TimeUnit;
|
|||||||
public class Trivia
|
public class Trivia
|
||||||
{
|
{
|
||||||
private static final org.slf4j.Logger LOGGER = LoggerFactory.getLogger(Trivia.class);
|
private static final org.slf4j.Logger LOGGER = LoggerFactory.getLogger(Trivia.class);
|
||||||
private static final String triviaLink = "https://opentdb.com/api.php?amount=10&type=multiple&category=";
|
private static final String TRIVIA_API_LINK = "https://opentdb.com/api.php?amount=10&type=multiple&category=";
|
||||||
private static final String categoriesLink = "https://opentdb.com/api_category.php";
|
private static final String TRIVIA_API_CATEGORIES_LINK = "https://opentdb.com/api_category.php";
|
||||||
|
|
||||||
public static List<String> channelsRunningTrivia = new ArrayList<>();
|
public static List<String> channelsRunningTrivia = new ArrayList<>();
|
||||||
|
|
||||||
@ -47,8 +47,8 @@ public class Trivia
|
|||||||
// first string is the channelId, the list contain all score records for that channel
|
// first string is the channelId, the list contain all score records for that channel
|
||||||
public static HashMap<String, LinkedList<TriviaScore>> channelAndScores = new HashMap<>();
|
public static HashMap<String, LinkedList<TriviaScore>> channelAndScores = new HashMap<>();
|
||||||
|
|
||||||
public static String getTriviaLink(int categoryId) {return triviaLink + categoryId; }
|
public static String getTriviaLink(int categoryId) {return TRIVIA_API_LINK + categoryId; }
|
||||||
public static String getCategoriesLink() {return categoriesLink; }
|
public static String getCategoriesLink() {return TRIVIA_API_CATEGORIES_LINK; }
|
||||||
|
|
||||||
public static String getNoDMsError() {
|
public static String getNoDMsError() {
|
||||||
return "\uD83D\uDE22 Sorry! Trivia doesn't work in DMs.";
|
return "\uD83D\uDE22 Sorry! Trivia doesn't work in DMs.";
|
||||||
|
@ -6,7 +6,6 @@ import net.dv8tion.jda.api.entities.User;
|
|||||||
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
import wtf.beatrice.hidekobot.Cache;
|
|
||||||
import wtf.beatrice.hidekobot.HidekoBot;
|
import wtf.beatrice.hidekobot.HidekoBot;
|
||||||
import wtf.beatrice.hidekobot.commands.base.ProfileImage;
|
import wtf.beatrice.hidekobot.commands.base.ProfileImage;
|
||||||
import wtf.beatrice.hidekobot.objects.MessageResponse;
|
import wtf.beatrice.hidekobot.objects.MessageResponse;
|
||||||
@ -57,8 +56,6 @@ public class AvatarCommand implements MessageCommand
|
|||||||
@Override
|
@Override
|
||||||
public void runCommand(MessageReceivedEvent event, String label, String[] args)
|
public void runCommand(MessageReceivedEvent event, String label, String[] args)
|
||||||
{
|
{
|
||||||
int[] acceptedSizes = Cache.getSupportedAvatarResolutions();
|
|
||||||
|
|
||||||
User user;
|
User user;
|
||||||
int resolution = -1;
|
int resolution = -1;
|
||||||
|
|
||||||
|
@ -16,7 +16,7 @@ public class DatabaseSource
|
|||||||
{
|
{
|
||||||
|
|
||||||
private static final org.slf4j.Logger LOGGER = LoggerFactory.getLogger(DatabaseSource.class);
|
private static final org.slf4j.Logger LOGGER = LoggerFactory.getLogger(DatabaseSource.class);
|
||||||
private static final String sqliteURL = "jdbc:sqlite:%path%";
|
private static final String JDBC_URL = "jdbc:sqlite:%path%";
|
||||||
private Connection dbConnection = null;
|
private Connection dbConnection = null;
|
||||||
private final String dbPath;
|
private final String dbPath;
|
||||||
|
|
||||||
@ -32,7 +32,7 @@ public class DatabaseSource
|
|||||||
|
|
||||||
public boolean connect()
|
public boolean connect()
|
||||||
{
|
{
|
||||||
String url = sqliteURL.replace("%path%", dbPath);
|
String url = JDBC_URL.replace("%path%", dbPath);
|
||||||
|
|
||||||
if(!close()) return false;
|
if(!close()) return false;
|
||||||
|
|
||||||
|
@ -13,8 +13,8 @@ public class MessageLogger extends ListenerAdapter
|
|||||||
{
|
{
|
||||||
// this class only gets loaded as a listener if verbosity is set to true on startup.
|
// this class only gets loaded as a listener if verbosity is set to true on startup.
|
||||||
|
|
||||||
private static final String guildChannelFormat = "[%guild%] [#%channel%] %user%: %message%";
|
private static final String GUILD_MESSAGE_LOG_FORMAT = "[%guild%] [#%channel%] %user%: %message%";
|
||||||
private static final String dmFormat = "[DM] %user%: %message%";
|
private static final String DIRECT_MESSAGE_LOG_FORMAT = "[DM] %user%: %message%";
|
||||||
|
|
||||||
private static final Logger LOGGER = LoggerFactory.getLogger(MessageLogger.class);
|
private static final Logger LOGGER = LoggerFactory.getLogger(MessageLogger.class);
|
||||||
|
|
||||||
@ -30,13 +30,13 @@ public class MessageLogger extends ListenerAdapter
|
|||||||
String guildName = ((TextChannel) event.getChannel()).getGuild().getName();
|
String guildName = ((TextChannel) event.getChannel()).getGuild().getName();
|
||||||
String channelName = event.getChannel().getName();
|
String channelName = event.getChannel().getName();
|
||||||
|
|
||||||
toLog = guildChannelFormat
|
toLog = GUILD_MESSAGE_LOG_FORMAT
|
||||||
.replace("%guild%", guildName)
|
.replace("%guild%", guildName)
|
||||||
.replace("%channel%", channelName);
|
.replace("%channel%", channelName);
|
||||||
}
|
}
|
||||||
else if(event.getChannel() instanceof PrivateChannel)
|
else if(event.getChannel() instanceof PrivateChannel)
|
||||||
{
|
{
|
||||||
toLog = dmFormat;
|
toLog = DIRECT_MESSAGE_LOG_FORMAT;
|
||||||
}
|
}
|
||||||
|
|
||||||
toLog = toLog
|
toLog = toLog
|
||||||
|
Loading…
Reference in New Issue
Block a user