@conflict/beta
Advanced tools
Comparing version 0.9.14 to 0.9.15
@@ -57,4 +57,4 @@ import View, { Component } from './view.js' | ||
export class InteractionResponse { | ||
constructor (interaction, onReply = () => {}) { | ||
this.onReply = onReply; | ||
constructor (interaction, vercelConfig) { | ||
this.vercelConfig = vercelConfig; | ||
this.interaction = interaction; | ||
@@ -142,3 +142,9 @@ if (interaction.options) { | ||
if (ephemeral && options[0] && options[0].toString() == '[object Object]') options[0].ephemeral = true; | ||
this.onReply?.(...options); | ||
if (this.vercelConfig?.isVercel) { | ||
return this.vercelConfig?.onReply?.({ | ||
type: 4, | ||
data: options[0], | ||
...(options[0]?.ephemeral ? { flags: 1 << 6 } : {}) | ||
}); | ||
} | ||
return ( | ||
@@ -176,2 +182,8 @@ this.interaction.conflictThunked ? | ||
if (!view.components) throw new Error('Missing components'); | ||
if (this.vercelConfig?.isVercel) { | ||
return this.vercelConfig?.onReply?.({ | ||
type: 7, | ||
data: view | ||
}); | ||
} | ||
return this.interaction.client.api.interactions(this.interaction.id, this.interaction.token).callback.post({ data: { | ||
@@ -185,4 +197,4 @@ type: 9, | ||
if (this.onReply) { | ||
view.applyTo({ reply: (...args) => { | ||
console.log('view!', args) | ||
this.onReply?.(...args); | ||
@@ -189,0 +201,0 @@ this.interaction.reply(...args); |
{ | ||
"name": "@conflict/beta", | ||
"version": "0.9.14", | ||
"version": "0.9.15", | ||
"description": "The first and only UI framework for Discord bots", | ||
@@ -5,0 +5,0 @@ "main": "exports.js", |
@@ -102,3 +102,3 @@ // dispatch.js | ||
const result = await new Promise(async (resolve, reject) => { | ||
const vercelOutput = await new Promise(async (resolve, reject) => { | ||
let resolved = false; | ||
@@ -115,6 +115,8 @@ | ||
try { | ||
let output = await command.execute(new InteractionResponse(interaction, (...data) => { | ||
console.log({data}) | ||
let output = await command.execute(new InteractionResponse(interaction, { | ||
isVercel: true, | ||
onReply: data => { | ||
console.log({data}); | ||
if (!resolved) resolve(data); | ||
})); | ||
}})); | ||
if (output instanceof Promise) output = await output; | ||
@@ -165,8 +167,3 @@ } catch (err) { | ||
return status(200, { | ||
type: 4, | ||
data: { | ||
content: "Hello! You can debug the following data:\n\n```json\n" + JSON.stringify({ result }, null, 4).substring(0, 1900) + "\n```", | ||
}, | ||
}); | ||
return status(200, vercelOutput); | ||
} else { | ||
@@ -173,0 +170,0 @@ return status(200, { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
93403
2375