@@ -195,6 +238,7 @@ const settingsStore = useSettingsStore();
const isPwd = ref(true);
const uploadKey = ref("");
+const discordWebhook = ref("");
const showAdvanced = ref(false);
window.messageApi.receive("settings-changed", (value) => {
@@ -206,8 +250,14 @@ watch(uploadKey, (newVal, oldVal) => {
settingsStore.settings.uploads.uploadKey = newVal;
});
+watch(discordWebhook, (newVal, oldVal) => {
+ if (newVal.length == 0) settingsStore.settings.uploads.uploadDiscord = false;
+ settingsStore.settings.uploads.discordWebhook = newVal;
+});
+
onMounted(() => {
uploadKey.value = settingsStore.settings.uploads.uploadKey;
+ discordWebhook.value = settingsStore.settings.uploads.discordWebhook;
});
/**
* @param {'api' | 'site' | 'endpoint'} type
diff --git a/src/layouts/DamageMeter.vue b/src/layouts/DamageMeter.vue
index f7f5567a..e2879948 100644
--- a/src/layouts/DamageMeter.vue
+++ b/src/layouts/DamageMeter.vue
@@ -127,6 +127,19 @@
+
+
+ Toggle Discord screenshot upload
+
+
{
+ if (!blob) return;
+
+ let msg = sessionState.value.currentBoss?.name || "No Boss";
+ msg += "\n";
+ msg += "Uploaded by ";
+ msg += sessionState.value.localPlayer || "Unknown";
+
+ void axios.postForm(
+ settingsStore.settings.uploads.discordWebhook,
+ {
+ "payload_json": JSON.stringify({
+ content: msg,
+ attachments: [{
+ id: 0,
+ filename: "screenshot.png",
+ content_type: "image/png",
+ }]
+ }),
+ "files[0]": blob,
+ }
+ );
+
+ },
+ "image/png",
+ 1
+ );
+
+ damageType.value = oldDamageType;
+
+ isTakingScreenshot.value = false;
+ Notify.create({
+ message: "Screenshot sent to Discord.",
+ color: "primary",
+ html: true,
+ actions: [
+ {
+ label: "Dismiss",
+ color: "white",
+ handler: () => {
+ /* ... */
+ },
+ },
+ ],
+ });
+
+ return "Screenshot sent to Discord."
+}
+
function requestSessionRestart() {
window.messageApi.send("window-to-main", { message: "reset-session" });
}
@@ -526,6 +608,18 @@ onMounted(() => {
});
}
}
+
+ if (
+ !isMinimized.value &&
+ settingsStore.settings.uploads.uploadDiscord &&
+ sessionState.value.currentBoss && // Only upload bosses
+ sessionState.value.lastCombatPacket !== lastScreenshotPacket && // No repeat uploads
+ sessionState.value.lastCombatPacket -
+ sessionState.value.currentBoss.lastUpdate < 3000 // Avoids uploading trash mobs
+ ) {
+ lastScreenshotPacket = sessionState.value.lastCombatPacket;
+ void uploadDiscordScreenshot()
+ }
}
} else {
Notify.create({
diff --git a/src/stores/settings.ts b/src/stores/settings.ts
index cfbd9158..7c1ca697 100644
--- a/src/stores/settings.ts
+++ b/src/stores/settings.ts
@@ -52,6 +52,8 @@ export const useSettingsStore = defineStore("settings", {
openOnUpload: false,
uploadUnlisted: true,
includeRegion: false,
+ uploadDiscord: false,
+ discordWebhook: "",
},
damageMeter: {
functionality: {