Skip to content
This repository was archived by the owner on Aug 11, 2023. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/main/java/de/staticred/dbv2/constants/FileConstants.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public class FileConstants {
public static final String FORCE_CLEAN_CHANNEL = "forceCleanChannel";

public static final String PREFIX = "prefix";
public static final String FOOTER = "footer";
public static final String INVALID_CHANNEL = "discord.invalidChannel";


Expand All @@ -43,4 +44,5 @@ public class FileConstants {

public static final File TEMP_DIRECTORY = new File(DBUtil.getINSTANCE().getDataFolder().getAbsolutePath() + "/temp");
public static final String ENABLE_DISCORD_PREFIX = "enablePrefixCommands";
public static final String ENABLE_SLASH_COMMANDS = "enableSlashCommands";
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,16 @@ public void onReady(ReadyEvent event) {
if (BotHelper.jda.getGuilds().size() != 0) {
BotHelper.guild = BotHelper.jda.getGuilds().get(0);

if (DBUtil.getINSTANCE().getConfigFileManager().enabledSlashCommands()) {
BotHelper.registerDefaultCommands();
}


BotHelper.registerDefaultCommands();
}

BotHelper.registerEvent(new MessageEvent());
if (DBUtil.getINSTANCE().getConfigFileManager().enabledDiscordMessages()) BotHelper.registerEvent(new MessageEvent());
BotHelper.registerEvent(new RoleCreateEvent());
BotHelper.registerEvent(new RoleDeleteEvent());
BotHelper.registerEvent(new SlashCommandEvent());
if (DBUtil.getINSTANCE().getConfigFileManager().enabledSlashCommands()) BotHelper.registerEvent(new SlashCommandEvent());

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ private BotHelper() {
*/
public static void startBot(String token) throws LoginException {
jda = JDABuilder.create(token, GatewayIntent.GUILD_MEMBERS, GatewayIntent.DIRECT_MESSAGES, GatewayIntent.GUILD_BANS, GatewayIntent.GUILD_MESSAGES, GatewayIntent.GUILD_PRESENCES).build();
jda.getPresence().setActivity(DBUtil.getINSTANCE().getConfigFileManager().getActivity());
if(!DBUtil.getINSTANCE().getConfigFileManager().getActivityDescription().isEmpty()) jda.getPresence().setActivity(DBUtil.getINSTANCE().getConfigFileManager().getActivity());
botstartup = System.currentTimeMillis();
registerEvent(new BotReadyEvent());
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/de/staticred/dbv2/discord/util/Embed.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public Embed(String context, String header, boolean useAuthorTag, Color color, S
if (useAuthorTag) {
SimpleDateFormat dateFormat = new SimpleDateFormat(DBUtil.TIME_PATTERN);
String time = dateFormat.format(new Date(System.currentTimeMillis()));
builder.setFooter(time + " sent by " + DBUtil.PLUGIN_NAME);
builder.setFooter(time + " sent by " + DBUtil.getINSTANCE().getMcMessagesFileHandler().getFooter());
}
}

Expand All @@ -44,7 +44,7 @@ public Embed(String context, String header, boolean useAuthorTag, Color color) {
if (useAuthorTag) {
SimpleDateFormat dateFormat = new SimpleDateFormat(DBUtil.TIME_PATTERN);
String time = dateFormat.format(new Date(System.currentTimeMillis()));
builder.setFooter(time + " send by " + DBUtil.PLUGIN_NAME);
builder.setFooter(time + " send by " + DBUtil.getINSTANCE().getMcMessagesFileHandler().getFooter());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,10 @@ public boolean enabledDiscordMessages() {
return configuration.getBoolean(FileConstants.ENABLE_DISCORD_PREFIX);
}

public boolean enabledSlashCommands() {
return configuration.getBoolean(FileConstants.ENABLE_SLASH_COMMANDS);
}

public String getActivityDescription() {
return configuration.getString(FileConstants.ACTIVITY_DESCRIPTION);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
public class MessagesFileHandler extends DBUtilFile {

/**
* Instantiates a new messages file handler.
*
* @param current the in resources
*/
Expand All @@ -25,6 +26,10 @@ public String getPrefix() {
return convertToMcString(configuration.getString(FileConstants.PREFIX));
}

public String getFooter() {
return configuration.getString(FileConstants.FOOTER);
}

public String getInvalidChannel() {
return convertToMcString(configuration.getString(FileConstants.INVALID_CHANNEL));
}
Expand Down
7 changes: 6 additions & 1 deletion src/main/resources/files/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ Token: ""
botActivityType: "WATCHING"

#Description of what the bot is doing
#Leave empty if you don't want to set an activity
botActitivyDescription: "DBUtil by StaticRed"

#If the bot should use discord ids for roles
Expand All @@ -39,9 +40,13 @@ listenToChannels:

#discordcommands using a prefix will be used.
#example: !help can be disabled when setting this to false
#WARNING: if discord commands do not have a slashcommandexecutor they´re not accessible anymore
enablePrefixCommands: true

#true: slash commands will be implemented
#WARNING: once slashcommands are enabled, you can only undo this with re-inviting your discord bot
#WARNING: if discord commands do not have a slashcommandexecutor they´re not accessible anymore
enableSlashCommands: false

#will delete all messages not resulting in a reply from the bot
#to make this work, listenToChannels may not be empty.
forceCleanChannel: false
Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/files/messages.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
prefix: "&3&lD&2&lB&8Util &0 >> &r"

#messages the bot sends in the discord
discord:
#discord settings
footer: "DBUtilities"