Fixed namecard fonts
This commit is contained in:
20
bot.js
20
bot.js
@@ -29,26 +29,6 @@ const launch = async () => {
|
|||||||
if (message.content === '/login' && isGuildOwner) {
|
if (message.content === '/login' && isGuildOwner) {
|
||||||
await message.reply(data.instagramTokenManager.getOauthUrl());
|
await message.reply(data.instagramTokenManager.getOauthUrl());
|
||||||
}
|
}
|
||||||
if (message.content === '/name-card-test' ) {
|
|
||||||
try {
|
|
||||||
const avatarUrl = message.author.displayAvatarURL({ extension: 'png', size: 512 });
|
|
||||||
const username = message.author.displayName;
|
|
||||||
|
|
||||||
const result = await launchWorker({
|
|
||||||
templatePath: data.nameCardTemplate,
|
|
||||||
avatarURL: avatarUrl,
|
|
||||||
username: username,
|
|
||||||
});
|
|
||||||
|
|
||||||
const attachment = new AttachmentBuilder(Buffer.from(result.result), { name: 'namecard.png' });
|
|
||||||
|
|
||||||
const channel = await message.guild.channels.fetch(data.welcomeChannelID);
|
|
||||||
await channel.send({ files: [attachment] });
|
|
||||||
|
|
||||||
} catch (err) {
|
|
||||||
await Logger.error('Failed to generate/send name card:', err);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
data.client.on('guildMemberAdd', async (member) => {
|
data.client.on('guildMemberAdd', async (member) => {
|
||||||
|
|||||||
@@ -1,8 +1,16 @@
|
|||||||
import { createCanvas, loadImage } from "@napi-rs/canvas";
|
import {createCanvas, GlobalFonts, loadImage} from "@napi-rs/canvas";
|
||||||
|
import path from "path";
|
||||||
|
import { fileURLToPath } from "url";
|
||||||
|
|
||||||
export class NameCardCreator {
|
export class NameCardCreator {
|
||||||
constructor(templatePath) {
|
constructor(templatePath) {
|
||||||
this.templatePath = templatePath;
|
this.templatePath = templatePath;
|
||||||
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
||||||
|
const fullPath = path.join(__dirname, "../../assets/fonts/Fredoka/static/Fredoka-Bold.ttf");
|
||||||
|
GlobalFonts.registerFromPath(
|
||||||
|
fullPath,
|
||||||
|
"Fredoka Bold"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user