Git Product home page Git Product logo

glitchii / embedbuilder Goto Github PK

View Code? Open in Web Editor NEW
238.0 5.0 85.0 4.7 MB

A Discord embed builder with both a GUI and JSON editor to use with Discord bots, webhooks, and other applications

Home Page: https://glitchii.github.io/embedbuilder/

License: MIT License

CSS 14.94% JavaScript 71.53% HTML 13.53%
embed-visualizer discord-embed-builder discord-embed embed-builder discord discord-json-embed discord-json embed embed-builder-discord discord-webhook

embedbuilder's Introduction

An embed visualizer

Visualize embed or message content from JSON input or provided GUI editor.

This can be used for discord bot embed commands. It can also be intergreted into your Discord bot's website.

Aside the JSON editor, it also includes a GUI editor which converts to JSON for simplicity.

GUI image JSON image

Supported URL Parameters

Editor param (/?editor=json)

The GUI editor is used by default. If 'editor' parameter is set with it's value set to "json", the website will use the JSON editor by default instead. Setting the value to anything else other than 'json' will be ignored.

Example URL: https://glitchii.github.io/embedbuilder/?editor=json

Data param (/?data=...)

A data param is used to specify the dafault json data to be used when the website loads. Note that value of the data param should be URL encoded first, then base64 encoded last because some characters like emojis can't be Base64 encoded alone. Calling the jsonToBase64() or jsonToBase64(json, true) function does that for you and returns the encoded JSON data.

Example URL:
https://glitchii.github.io/embedbuilder/?data=JTdCJTIyZW1iZWQlMjIlM0ElN0IlMjJ0aXRsZSUyMiUzQSUyMkxvcmVtJTIwaXBzdW0lMjIlMkMlMjJkZXNjcmlwdGlvbiUyMiUzQSUyMkRvbG9yJTIwc2l0JTIwYW1ldC4uLiUyMiUyQyUyMmNvbG9yJTIyJTNBMzkxMjklN0QlN0Q=

Other parameters

Params that end with = in the list below need a value, those that don't will always be truthy when set either with or with no value.

Parameter               Description
---------               -----------
username=               Used to set the default name of the bot.
avatar=                 Avatar for the bot. Either URL encode it or make this the last param.
verified                Displays a verified badge on the bot tag when set to true.
reverse                 Reverse the preview and editors position.
nouser                  Display embed or message content with no username or avatar.
embed                   Display only the embed, no editor.
guitabs=                Specify what gui tabs to display comma seperated.
                        Example: `guitabs=author` or `guitabs=image,footer`
placeholders            Silences some warrnings, e.g. warrnings about missing url protocols or incorrect footer timestamps.
                        With this param, automatic insertion of the 'http' protocol for urls written without a protocol is also disabled.
                        This param is useful when your bot allows having placeholders in place of a URL eg. `{ server.url }`
placeholders=errors     This also disables automatic insertion of 'http' for urls without a protocol.
                        Except, warnings won't be silenced. The user will still see a warning that a url or timestamp (etc.) is incorrect for 5 seconds.
hideditor               Hides the editor.
hidepreview             Hides the preview.
hidemenu                Hides the three dotted menu.
single                  Use only a single embed instead of the default multi-embeds. JSON structure will be different too.
                        When 'nomultiembedsoption' is set, this option is ignored and default builder config is used.
nomultiembedsoption     Remove multi-embeds option from the menu.
                        Together with the 'single' option, this allows
                        the developer to force the user to either use only a single or multi-embeds.
sourceOption            Display link to source code in menu. (Off by deafult unless enabled or top domain host is glitchii.github.io)
data=                   URL + Base64 encoded string of json data to be used on the embed instead of the default. 

Case matters, all parameters should be lowercase.

Example URL with all* the above parameters:

https://glitchii.github.io/embedbuilder/?username=Troy&verified&reverse&guitabs=image,footer&avatar=https://cdn.discordapp.com/avatars/663074487335649292/576eb5f13519b9da10ba7807bdd83fab.webp

Alternative to URL options:

This will only work on a cloned repo of the builder: Have a JavaScript config file named builder.config.js. In this file, define window.options to an object containing the params. Note that some param names and cases will be different from the URL ones. An example builder.config.js file is included in the repo. The config file is loaded before the main script and because it's a JS file, you can do and probably alter anything else.

Intergretting into your website

You are free to use/fork/clone this in your website. Intergretting into your websites allows sending the embed to Discord with a few changes, and using 'formatters' eg. '{ server.name }' or '{ user.name }' etc. A (not so bad) downside would be that you'd probably have to keep up with fixes and updates.


If you want to keep up to date and all you want is to have an embed builder in your website with no additional features and maybe using your own bot name and avatar, etc., then you might iframe https://glitchii.github.io/embedbuilder into your website with a few of the parameters above if needed instead. The downside to this is that due to security reasons, browsers won't allow features like updating URL parameter to work through iframes, whoever URL options will still be read from the top holder of the iframe, those are probably the only features that won't work and thus are removed from the GUI menu when embeded in iframe. `builder.config.js` also won't be seen in iframe



You can look into the project boards to see what is being worked on or If you want to contribute.

Example integration: https://troybot.xyz/embed
To Do | Discussions

embedbuilder's People

Contributors

cayeoficial avatar glitchii avatar manhbi18112005 avatar nobu-sh avatar rock583 avatar x1xo avatar zignis avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

embedbuilder's Issues

Feature Request: Edit Embeds Already Posted

Like the title says. I would love to replace CarlBot as all I use it for is embeds. CarlBot has commands to edit embeds it has posted such as.
embedsource <msg_ID> [channel]
then running ecembed <msg_ID> <JSON/Pastebin_Link/Starb.in_Link>
to edit the updated embed if this could be done in the editor even better but I would settle for commands :D

Iframe doesn't work

The problem is that if I try to implement the code as a iframe to my website, I get this error below.
image

Request Failed

After choose photo from button Browse
Show me error : Request Failed (Check Dev-Tool)
What That?

Editing a field creates a new object with Grammarly

When editing an existing field, a new value object is created. A simple fix to this is to make minor changes to the index.js file. At line 454, replace

let jsonField = json.embed.fields[Array.from(fields.children).indexOf(field)];

with

let jsonField = json.embed.fields[Array.from(fields.children).indexOf(field)-2];

Source: Invalid array index

Edit:
-2 isn't a permanent / efficient fix, the extension was messing up with the textarea

Add limits info

Embeds have some limits:

  • Title is limited to 256 characters
  • Description is limited to 4096 characters
  • An embed can contain a maximum of 25 fields
  • A field name/title is limited to 256 character and the value of the field is limited to 1024 characters
  • Footer is limited to 2048 characters
  • Author name is limited to 256 characters
  • The total of characters allowed in an embed is 6000

It would be helpful to add some (maybe toggle show/hide) character counters and field counters. While text already stops when you hit the character count limit, and you already get an error message when trying to add a 26th field, etc. knowing how close you are to hitting the cap can be helpful. The overall 6000 character limit is especially tough to add up as you're developing an embed.

Text offcentered on mobile

For some fields, such as Title, the text appears slightly raised from the box.
Appears to happen on IOS Web Kit, Haven't tested on Android and works correctly on Desktop.
Happens both inside and outside of an Iframe
image
image

ReferenceError: hljs is not defined

Error: ReferenceError: hljs is not defined
Found at: Bottom of the page. Fired by:

error = (msg, time) => {
            notif.innerHTML = msg, notif.style.display = 'block';
            time && setTimeout(() => notif.animate({ opacity: '0', bottom: '-50px', offset: 1 }, { easing: 'ease', duration: 500 })
                .onfinish = () => notif.style.removeProperty('display'), time);
            return false;
        }

At lines 96 - 101


Reproduction Steps:

  • Clone repo
  • Run index.js

Indent Display

If you use the '>' indentation on your embed builder with more than one line it disposes of all but the first line.

Example to reproduce:
In a single embed field on your builder type the following.

test 1
test 2

Only test 1 will show in the preview.

Tested on Chromium based browser.

Annoying behaviour of Title field

When editing the Title field, then collapsing or expanding another field and going back to the Title field, it collapses. so you have to expand it again to edit it. I guess this is because the Title field can't really expand and therefore the editing field and the expanding/collapsing hitbox overlap, leading to this behaviour.

Would appreciate a fix, really like the builder!

?data= parameter breaks utf8

This is my data parameter:
JTdCJTIyY29udGVudCUyMjolMjIlMjIsJTIyZW1iZWRzJTIyOiU1QiU3QiUyMnRpdGxlJTIyOiUyMioqU3RyZWFrJTIwemVyc3QlQzMlQjZydCEqKiUyMiwlMjJ0eXBlJTIyOiUyMnJpY2glMjIsJTIyZGVzY3JpcHRpb24lMjI6JTIyRGllJTIwJTNDIzg2MDg5MzM4NzY0NTY0ODkwNiUzRSUyMFN0cmVhayUyMHd1cmRlJTIwZ2Vicm9jaGVuOiU1Q25FcndhcnRldGUlMjBaYWhsOiUyMDE0JTVDbklucHV0JTIwdm9uJTIwJTNDQDk4MDQzNzQyOTI1NTMwNzMxNCUzRTolMjAxJTIyLCUyMmNvbG9yJTIyOjE2NzExNjgwLCUyMmZvb3RlciUyMjolN0IlMjJ0ZXh0JTIyOiUyMlNvbGx0ZSUyMGRlciUyMEVpbmRydWNrJTIwZW50c3RlaGVuLCUyMGRhcyUyMGRpZSUyMFN0cmVhayUyMGFic2ljaHRsaWNoJTIwemVyc3QlQzMlQjZydCUyMHd1cmRlJTIwdW5kJTIwZXMlMjBuaWNodCUyMGRhcyUyMGVyc3RlJTIwbWFsJTIwaXN0LCUyMGJpdHRlJTIwZW50c3ByZWNoZW5kZSUyME1hJUMzJTlGbmFobWVuJTIwZXJncmVpZmVuKHouQiUyMEF1c3NjaGx1c3MlMjB2b20lMjBDaGFubmVsKSElMjIlN0QlN0QlNUQlN0Q=

It was first URLEncoded and then hashed with base64.
When I manually reverse the process, everything works as it should. But when I open the url with the data parameter some characters break(Ü, Ö, ß etc., see below)
image

Delete embed properties which are set to "" or empty array

Discord's api now doesn't support parsing of json embeds with empty properties like this:
{"embed":{"title":"","description":"Hello! This won't work because title is empty and thumbnail url too!","color":4321431,"thumbnail":{"url":""}}}

So, I suggest to delete the property instead of letting it be "" (or empty array in case of fields), because discord doesn't support this now and this only causes problems.
It will look like this: {"embed":{"description":"Yay! No empty properties, now it works!","color":4321431}}

Same thing for content

Preview Issue

If you don't provide any guiTabs in the builder.config.js, the preview of the embed is broken. If you add in the assets/js/script.js on line 962 a if statement if there are any values inside the tabs array, you can prevent this.

E.g:

if (tabs.length) {
    for (const e of document.querySelectorAll(\`.${tabs.join(', .')}\`))  e.classList.add('active');
}

currentURL is not a function

Getting TypeError: currentURL is not a function when Auto-update URL options (if this is checked will get the error on window load) and Auto-update data link URL are checked.

Question

This is a nice integration, but can you make it that you can press a button and paste a webhook url in and send it to a channel instand?

didnt work with express and ejs

idk wtf is wrong with the code so that it wont show correctly on my bot dashboard?
it works fine when i open it with live server
Screenshot_2022-06-11_13-09-03
Screenshot_2022-06-11_13-09-37
Screenshot_2022-06-11_13-10-15
Screenshot_2022-06-11_13-10-40

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.