adding notes

This commit is contained in:
2024-08-06 23:14:28 +02:00
parent 0b8607d03b
commit 784f11206d
5 changed files with 214 additions and 15 deletions
@@ -8,6 +8,7 @@ import net.dv8tion.jda.api.interactions.InteractionContextType;
import net.dv8tion.jda.api.interactions.commands.OptionType;
import net.dv8tion.jda.api.interactions.commands.build.Commands;
import net.dv8tion.jda.api.interactions.commands.build.OptionData;
import org.jetbrains.annotations.Nullable;
import java.io.*;
import java.util.Collections;
@@ -22,6 +23,7 @@ public class Main {
private static final Properties properties = new Properties();
private static String version = "Unknown version";
private static Storage storage;
private static Long adminId;
public static JDA jda;
public static void main(String[] args) throws InterruptedException {
@@ -43,6 +45,8 @@ public class Main {
logger.info("Starting " + version);
adminId = Long.parseLong(properties.getProperty("ADMIN_USER_ID"));
jda = JDABuilder.createLight(properties.getProperty("DISCORD_TOKEN"), Collections.emptyList())
.setCallbackPool(Executors.newVirtualThreadPerTaskExecutor())
.setActivity(Activity.customStatus("Notekeeping..."))
@@ -58,8 +62,24 @@ public class Main {
new OptionData(OptionType.BOOLEAN, "ephermeal", "Whether the note should be ephermal").setRequired(false)
)
.setContexts(InteractionContextType.BOT_DM, InteractionContextType.GUILD, InteractionContextType.PRIVATE_CHANNEL)
)
.queue();
).queue();
jda.upsertCommand(Commands.slash("add-note", "Add a note")
.setIntegrationTypes(IntegrationType.GUILD_INSTALL, IntegrationType.USER_INSTALL)
.addOptions(
new OptionData(OptionType.STRING, "alias", "An alias for the note").setRequired(true),
new OptionData(OptionType.STRING, "title", "The title of the note").setRequired(true),
new OptionData(OptionType.STRING, "content", "The content of the note").setRequired(true),
new OptionData(OptionType.STRING, "image-url", "The image URL of the note").setRequired(false),
new OptionData(OptionType.STRING, "thumbnail-url", "The thumbnail URL of the note").setRequired(false),
new OptionData(OptionType.STRING, "color", "The color of the note").setRequired(false),
new OptionData(OptionType.STRING, "author", "The author of the note").setRequired(false),
new OptionData(OptionType.STRING, "author-url", "The author URL of the note").setRequired(false),
new OptionData(OptionType.STRING, "footer", "The footer of the note").setRequired(false),
new OptionData(OptionType.STRING, "footer-url", "The footer URL of the note").setRequired(false)
)
.setContexts(InteractionContextType.BOT_DM)
).queue();
}
@@ -89,10 +109,19 @@ public class Main {
}
}
@Nullable
public static Long getAdminId() {
return adminId;
}
public static String getVersion() {
return version;
}
public static Storage getStorage() {
return storage;
}
private static void shutdown() {
jda.shutdown();
storage.shutdown();