@conflict/beta
Advanced tools
Comparing version 0.2.0 to 0.3.0
@@ -39,2 +39,3 @@ import View from './view.js' | ||
this.member = interaction.member; | ||
this.author = interaction.member.user; | ||
this.token = interaction.token; | ||
@@ -54,4 +55,4 @@ this.type = interaction.type; | ||
} | ||
editReply (options) { | ||
return this.interaction.reditReply(options); | ||
editReply (...options) { | ||
return this.interaction.reditReply(...options); | ||
} | ||
@@ -64,4 +65,4 @@ deleteReply () { | ||
} | ||
followUp (options) { | ||
return this.interaction.followUp(options); | ||
followUp (...options) { | ||
return this.interaction.followUp(...options); | ||
} | ||
@@ -86,7 +87,7 @@ inGuild () { | ||
} | ||
reply (options) { | ||
return this.interaction.reply(options); | ||
reply (...options) { | ||
return this.interaction.reply(...options); | ||
} | ||
respond (options) { | ||
return this.interaction.reply(options); | ||
respond (...options) { | ||
return this.interaction.reply(...options); | ||
} | ||
@@ -96,5 +97,10 @@ getView () { | ||
} | ||
view (view) { | ||
return this.interaction.reply(new View(view)); | ||
view (view, options) { | ||
if (!(view instanceof View)) view = new View(view); | ||
view.applyTo(this.interaction, options, true); | ||
} | ||
privateView (view, options) { | ||
view.ephemeral = true; | ||
this.view(view, options); | ||
} | ||
sendView (options) { | ||
@@ -105,5 +111,5 @@ if (!view instanceof View) return; | ||
} | ||
update (options) { | ||
update (...options) { | ||
if (this.interaction.update) return this.interaction.update(options); | ||
return this.reply(options); | ||
return this.reply(...options); | ||
} | ||
@@ -110,0 +116,0 @@ } |
@@ -1,5 +0,7 @@ | ||
import ActionRow from './components_dist/ActionRow.js'; | ||
import Button from './components_dist/Button.js'; | ||
import ActionRow from './components/dist/ActionRow.js'; | ||
import Button from './components/dist/Button.js'; | ||
import Embed from './components/dist/Embed.js'; | ||
import Attachment from './components/dist/Attachment.js'; | ||
export { ActionRow, Button } | ||
export default { ActionRow, Button } | ||
export { ActionRow, Button, Embed, Attachment } | ||
export default { ActionRow, Button, Embed, Attachment } |
{ | ||
"name": "@conflict/beta", | ||
"version": "0.2.0", | ||
"version": "0.3.0", | ||
"description": "The first and only UI framework for Discord bots", | ||
"main": "exports.js", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
"test": "echo \"Error: no test specified\" && exit 1", | ||
"components": "cd components && npx babel src --out-dir dist" | ||
}, | ||
@@ -46,3 +47,11 @@ "repository": { | ||
}, | ||
"devDependencies": { | ||
"@babel/cli": "^7.16.0", | ||
"@babel/core": "^7.16.5", | ||
"@babel/parser": "^7.16.6", | ||
"@babel/plugin-transform-react-jsx": "^7.16.5", | ||
"@babel/preset-env": "^7.16.5", | ||
"@babel/preset-react": "^7.16.5" | ||
}, | ||
"type": "module" | ||
} |
20
view.js
@@ -41,3 +41,3 @@ import Discord from 'discord.js'; | ||
if (!object[child.tag] && child.tag === 'embeds') object[child.tag] = []; | ||
// if (!object[child.tag] && child.tag === 'embeds') object[child.tag] = []; | ||
if (!object[child.tag] && child.tag === 'components') object[child.tag] = []; | ||
@@ -55,3 +55,3 @@ | ||
let keys = Object.keys(object); | ||
if (keys.length == 1 && keys[0] === 'embed' && tag === 'embeds') object = object[keys[0]]; | ||
// if (keys.length == 1 && keys[0] === 'embed' && tag === 'embeds') object = object[keys[0]]; | ||
if (keys.length == 1 && keys[0] === 'hstack' && tag === 'vstack') object = object[keys[0]]; | ||
@@ -67,5 +67,3 @@ //console.log('isComponent', keys.length == 1 && keys[0] === 'component' && tag === 'components'); | ||
export function recursiveArray (tree) { | ||
console.log('[recursiveArray]', tree); | ||
for (const key in tree) { | ||
console.log(key, key.includes('$')); | ||
let newName; | ||
@@ -76,4 +74,2 @@ if (key.includes('$')) { | ||
else { | ||
console.log('[value]', (tree[key])); | ||
console.log('[values]', Object.values(tree[key])); | ||
tree[newName] = [Object.values(tree[key])[0]]; | ||
@@ -84,6 +80,4 @@ } | ||
if (tree[key] instanceof Array) { | ||
console.log('[typeArray]', tree[key]); | ||
tree[key] = tree[key].map(item => recursiveArray(item)); | ||
} else if (newName && tree[newName] instanceof Array) { | ||
console.log('[typeArray]', tree[newName]); | ||
tree[newName] = tree[newName].map(item => recursiveArray(item)); | ||
@@ -111,4 +105,7 @@ } else if (typeof tree[key] == 'object') tree[key] = recursiveArray(tree[key]); | ||
let $hooks = []; | ||
let attachments = []; | ||
for (const key in parsed) { | ||
this[key] = parsed[key]; | ||
if (key === 'attachments') { | ||
attachments = parsed[key]; | ||
} else this[key] = parsed[key]; | ||
} | ||
@@ -123,6 +120,5 @@ this.callback = async function (message) { | ||
} | ||
this.applyTo = async function (channel) { | ||
let output = channel.send(this); | ||
this.applyTo = async function (channel, options, isInteraction) { | ||
let output = isInteraction ? channel.reply(this, options, ...attachments) : channel.send(this, ...attachments); | ||
if (output instanceof Promise) output = await output; | ||
console.log(output, output instanceof Discord.Message); | ||
if (output instanceof Discord.Message) { | ||
@@ -129,0 +125,0 @@ let hooks = $hooks; |
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
41765
23
1152
6