Skip to content

Commit

Permalink
Improve examples section
Browse files Browse the repository at this point in the history
  • Loading branch information
A-K-O-R-A committed Mar 3, 2022
1 parent ccc0790 commit 542b6f1
Show file tree
Hide file tree
Showing 7 changed files with 1,198 additions and 0 deletions.
Binary file added examples/avatar.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added examples/minimal/background.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added examples/minimal/card.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
27 changes: 27 additions & 0 deletions examples/minimal/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
const { drawCard, Text } = require('discord-welcome-card');
const { writeFile } = require('fs/promises');
const { join } = require('path');
const { member, avatar } = require('../mock');

async function run() {
const image = await drawCard({
theme: 'dark',
blur: false,
rounded: true,
text: {
title: new Text('Welcome!', 240, 70).setFontSize(32),
text: new Text(member.user.tag, 240, 150).setFontSize(64),
color: `#DDDDDD`,
font: 'Panton Black Caps',
},
avatar: {
image: avatar,
outlineWidth: 5,
outlineColor: `#DDDDDD`,
},
background: join(__dirname, './background.png'),
});

writeFile(join(__dirname, './card.png'), image);
}
run();
20 changes: 20 additions & 0 deletions examples/mock.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
const { join } = require('path');
const path = (...s) => join(__dirname, ...s);

const avatar = path('./avatar.png');

/** @type {import('discord-welcome-card').GuildMemberLike} */
const member = {
user: {
tag: 'Dyno#3861',
displayAvatarURL: ({ format }) => avatar,
},
guild: {
memberCount: 420,
},
};

module.exports = {
member,
avatar,
};
Loading

0 comments on commit 542b6f1

Please sign in to comment.