-
-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
EmbedParser doesn't work #119
Comments
I missed the parser in https://github.com/imranbarbhuiya/TagScript/tree/main/packages/tagscript#transformers example. You need to add const { Interpreter, StringTransformer, StrictVarsParser } = require("tagscript")
const ts = new Interpreter(new StrictVarsParser());
let result = await ts.run('{args}', { args: new StringTransformer('Hi, How are you?') });
console.log(result) |
examples are updated now |
Is the documents for parsers for the module I can't seem to get the RequiredParser to work const { Interpreter } = require("tagscript")
const { RequiredParser } = require("tagscript-plugin-discord")
let ts = new Interpreter(new RequiredParser())
let result = await ts.run("{require(757425366209134764, 668713062186090506, 737961895356792882):You aren't allowed to use this tag.}")
console.log(result) Result:
Is there anything I need to parse in for this to work? |
It's working as expected. In the const { Interpreter } = require("tagscript")
const { RequiredParser } = require("tagscript-plugin-discord")
let ts = new Interpreter(new RequiredParser())
let result = await ts.run("{require(757425366209134764, 668713062186090506, 737961895356792882):You aren't allowed to use this tag.}")
console.log(result)
if (!result.actions.require.ids.includes(interaction.user.id)) {
// u can have channel, role, too
return interaction.reply(result.actions.require.message)
} Adding a guide with all these uses is planned. Till then, I'll try to add as much documentation as possible in my free time. |
Last question, how do I use EmbedParser? Really appreciate you helping me. |
let embed
if (result.actions.embed) {
embed = new EmbedBuilder(response.actions.embed);
} |
I can't seem to find the embed property in the actions object const { Interpreter } = require("tagscript")
const { EmbedParser } = require("tagscript-plugin-discord")
let ts = new Interpreter(new EmbedParser())
let result = await ts.run('{ embed: { "title": "Hello!", "description": "This is a test embed." } }')
console.log(result) output:
The embed property is not found in the actions object |
space before |
Is there any way to parse in values into the EmberParser? { embed: {
"title": "Here's a random duck!",
"image": { "url": {user.avatar} },
"color": 15194415
} } This returns an JSON error:
Is there any way to parse in the user's avatar into the embed? |
I am also unable to parse in images or thumbnails using the properties method. {embed(title):Rules}
{embed(description):Follow these rules to ensure a good experience in our server!}
{embed(thumbnail):{user.avatar}} The embed output: {
"title":"Rules",
"description":"Follow these rules to ensure a good experience in our server!",
"thumbnail":"https://cdn.discordapp.com/avatars/958188607494049792/b5e6cd7d5380e58e6fe14c3668f02714.webp"
} This returns an error:
This is because the url needs to be nested further in the {
"title":"Rules",
"description":"Follow these rules to ensure a good experience in our server!",
"thumbnail":{
"url":"https://cdn.discordapp.com/avatars/958188607494049792/b5e6cd7d5380e58e6fe14c3668f02714.webp"
}
} How do I fix this issue? |
Also another bug I came to find is the color not being parsed as an integer: {embed(title):test}
{embed(color):0x2F3036} The JSON value returned: {
"title":"test",
"color": "0x2F3036"
} The Discord API for whatever reason only accepts number, which when parsing the embed into the This however is an easy fix, all you need to do is convert the hex code to an integer: if(res.actions?.embed.color) {
res.actions.embed.color = parseInt(res.actions.embed.color.replace("#", ""), 16)
} You might want to fix this in the package. |
You need to use const { Interpreter } = require("tagscript")
const { EmbedParser } = require("tagscript-plugin-discord")
let ts = new Interpreter(new EmbedParser())
let result = await ts.run(`{embed:{
"title": "Here's a random duck!",
"image": { "url": "{user.avatar}" },
"color": 15194415
} }`)
console.log(result) and add |
This definitely needs to be changed but it'll be a breaking change so create a new issue and I'll fix it in the next major release (not very soon tho) till then you can fix it like this const embedData = result,actions.embed;
if (embedData) {
if(typeof embedData.thumbnail === 'string') embedData.thumbnail = {url: embedData.thumbnail};
// same for image
embed = = new EmbedBuilder(embedData);
} |
I'm adding a fix for this |
Can you try installing #120 pr and see if it fixes your color issue yarn add tagscript-plugin-discord@pr-120
# or
npm installl tagscript-plugin-discord@pr-120 |
No, I am still getting the same error:
The Embed: {embed(title):TEST}
{embed(color):0x2F3036} Package Version: "tagscript-plugin-discord": "^2.0.6-pr-120.8c92f9f.0" |
Hm, interesting. If you see this test, it's similar to your one. I'll test with your input
|
For some reason, the last release released main branch even tho I selected the pr 😞 I've released a new version |
It's working as expected now |
great, I'll release it in a few minute |
Code:
Returns:
Shouldn't the output be:
Plugins such as
tagscript-plugin-discord
doesn't work as well, when using transformers.Package Versions:
The text was updated successfully, but these errors were encountered: