Code Monkey home page Code Monkey logo

invidget's People

Contributors

almeidx avatar angelocore avatar asyatheabove avatar dependabot[bot] avatar doges avatar fersilva16 avatar flicksie avatar gaminggeek avatar isak-dombestein avatar justandras avatar manudoma avatar metehus avatar mome0320 avatar mrcerise avatar neunat avatar pauleks avatar pedrofracassi avatar perronosaurio avatar phoenix616 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

invidget's Issues

Align these correctly @metehus

invidget/src/index.js

Lines 100 to 105 in 14debfb

// TODO: Align these correctly @metehus
// Online and member counts
const presenceCircle = canvas.circle(8).move(INNER_X, INNER_Y + SERVER_NAME_SIZE + 2).fill('#43b581')
const presenceText = canvas.path(whitneySemibold.getD(locale.online.replace('{{count}}', invite.approximate_presence_count.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",")), { x: INNER_X + 8, y: 16 + 12 + 12 + 30, anchor: 'left top', fontSize: 14 })).fill('#b9bbbe')
canvas.path(whitneySemibold.getD(locale.members.replace('{{count}}', invite.approximate_member_count.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",")), { x: INNER_X, y: 16 + 12 + 12 + 60, anchor: 'left top', fontSize: 14 })).fill('#b9bbbe')


This issue was generated by todo based on a TODO comment in 14debfb. It's been assigned to @pedrofracassi because they committed the code.

Handle invisible portions of icons better

Currently invisible portions of server icons get some strange outline around them when the normal invite widget just displays the normal background.

Invidget:
Invidget

Discord widget:
Discord

Option to use server ID too

Although using invites directly is usually enough, I thought it'd be cool to also be able to use a server ID instead.

My main concern is that invites are not guaranteed to last long, and to actually generate an invite that doesn't expire, the user has to do some manual configuration of it, and even then, it's easy to accidentally delete an invite without even realizing the things it could have broken.

My suggestion is to allow the server ID to also be used to generate the widget, that way it's more resilient to accidents like deleting an invite or using one that expires.

The setup would be like so:

  1. Go to Server Settingsโ‡’Widget
  2. Enable Server Widget
  3. Set Invite Channel to the desired channel

Once this is done, Discord will automatically generate an invite, and regenerate it once it expires or if it's deleted.

Invites

The invite on the top, created by "Information", is the automatically generated one.

To get the current invite by using the server ID, a request can be made to https://discordapp.com/api/guilds/<server-id>/widget.json with the corresponding <server-id>, and the response will look like so:

{
  "id": "<server-id>",
  "name": "My Server",
  "instant_invite": "https://discordapp.com/invite/<invite-code>",
  "channels": [...],
  "members": [...],
  "presence_count": 3
}

The key instant_invite has the full invite URL, and the invite code is the last portion of the URL.

This way, if a server has widgets enabled and an invite channel set, its server ID can be used to get the latest valid invite link.

Handle text overflow

Text might go out of bounds if a server name or the number of members online/present are too big. We should handle that by adding an ellipsis (...) and shortening the text.

Discord

image

invidget

image

Special characters don't work correctly

After Japanese support was added in #9, I've noticed that the renderer doesn't handle special characters correctly.

Example: https://invidget.switchblade.xyz/discord-developers?language=ja

image

Handle invalid invites gracefully

Currently, when an invite is invalid, we simply don't respond to the request. Instead, we should handle invalid invites just like Discord does: by displaying an "invalid invite" with a poop icon where the invite would be:

image

Use on a static MkDocs website on GitHub pages

I'm thinking about linking ~40 discord invites on my website.

I'm thinking in GitHub actions to run a script before compiling which parses all the invidget URLs hosted on your official instance, and cloning your project and generating the URLs and replacing the links by these svg files

This means I'm using your instance when developping
But when the website is live it's all hosted on my insurance, though it's static and won't update until next change which I'm fine with

what do you think / has this been done before?

Only getting a 404?

I had no issues with this until today when I noticed my link now shows a 404. The invite still works.

https://invidget.switchblade.xyz/nhS4f9PJpg?2

Add Emoji support

Some Discord servers have emoji in their names, but we currently don't render them.

Discord

image

invidget

image

Support

Servers Down I guess Widgets Not Working

[Feature] Add an option to convert svg to png in url parameters

It would be cool that if someone added ?format=png to the end of the URL, the image is automatically converted to a PNG file. I might do a PR later on that if I have time
Edit: This is necessary when sending messages to discord, as discord does not allow embedded SVG for security reasons.

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.