2 months ago
I'm running a Discord bot on Railway, and right now I'm working on a generic image generation command. However, no matter how many fonts I try, Railway won't load any of them, and when I test the command, everything just shows up as tofu
Attachments
43 Replies
2 months ago
Can you try using Railpack instead of Nixpacks?
2 months ago
I guess Nixpacks isn't including your font in the final build, Railpack may include it but either way Nixpacks is deprecated for awhile already.
2 months ago
Oof, are you familiar with a Dockerfile?
2 months ago
I saw that you removed the fonts, I know you are installing them via APT but bring the old way back (in a folder inside your application).
I guess your canvas isn't picking them up via APT.
2 months ago
@Gofret if i may, i know its a crude solution but can fix your fonts issue
There is an api called cookie api that can generate images, but it uses google fonts. What you could do it use your code to generate everything except the font, and then send to cookie to generate the remaindfer of the image with the fonts. It is a free api too.
2 months ago
obvs may not be the right solution for you, but wanted to share how i did it
How long exactly does it take for this cookie API to generate the image? I can probably just get it to add the fonts.
2 months ago
sorry for late reply, The api takes up to about 2 seconds to generate an image.
<:Burnt_toast:1452711118995722487>
Attachments
2 months ago
have you got the api key from their website?
i did forget to mention, any images generated with cookie get deleted from their file storage after 7 days. If your generating images that are referenced when a command is run, shouldnt be an issue, but if you need those generated images kept, it make be a good idea to build a cf worker that can store them after they are made
2 months ago
2 months ago
that is the site for the api btw
2 months ago
its not very easy to find with searches tbh
2 months ago
youll be looking for the card builder function to generate images
it is all code for the api but a friend of mine made a builder for making the code for the images aswell
Yes, I got the API from their website, and the image is generated in real-time. The information needed to generate the image is from MongoDB and is updated almost daily.
The API key is what I got by clicking the "create API" button there, right? They also gave a root key, but I'm not sure about that one. @MrMech
2 months ago
as far as im aware, the api key is the only thing you need, give me a moment
2 months ago
curl -X POST "https://api.cookie-api.com/api/cards/card-builder/build?dev=true" -H "Authorization: YOUR_API_KEY" -H "Content-Type: application/json" -d '{"card":{"width":"700","height":"250","bg":"#6b4eff","bg_type":"color"},"elements":[{"id":"1","type":"discord_profile","user_id":"{DISCORD_USER_ID}","position":{"x":30,"y":45},"size":160},{"id":"2","type":"text","text":"{USERNAME}, welcome to {SERVER_NAME}","text_size":32,"font":"DM Sans","color":"#ffffff","position":{"x":220,"y":105}}]}'thats an example curl request i was working on before
Maybe cuz name I just made it up.
Attachments
2 months ago
oh, you dont have to add a discord bot to use the api
I think you misunderstood.
Attachments
2 months ago
this root key is the api key yeah
Attachments
2 months ago
yep thats it, sorry theyve updated the dashboard since i was last on lol
2 months ago
yeah my dashboard has nothing for the production keys part
Attachments
2 months ago
sure, i can try to help fix it
2 months ago
what is the request you are doing btw? if it has sensitive info blur it lol
2 months ago
Attachments
2 months ago
yeah its being removed immediatly, send in dms instead
2 months ago
mine are open