Skip to content

Commit

Permalink
🐛 Slugify strings
Browse files Browse the repository at this point in the history
  • Loading branch information
Androz2091 committed Jan 29, 2021
1 parent 2a42db7 commit 1a679cb
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
11 changes: 9 additions & 2 deletions events/guildMemberAdd.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
const stringCleaner = require("@sindresorhus/slugify");
const Canvas = require("canvas"),
Discord = require("discord.js");
const { resolve } = require("path");
Expand Down Expand Up @@ -60,8 +61,14 @@ module.exports = class {
ctx.drawImage(background, 0, 0, canvas.width, canvas.height);
// Draw username
ctx.fillStyle = "#ffffff";
ctx.font = applyText(canvas, member.user.username, 48);
ctx.fillText(member.user.username, canvas.width - 660, canvas.height - 248);
const username = stringCleaner(member.user.username, {
separator: " ",
lowercase: false,
decamelize: false,
preserveLeadingUnderscore: true,
});
ctx.font = applyText(canvas, username, 48);
ctx.fillText(username, canvas.width - 660, canvas.height - 248);
// Draw server name
ctx.font = applyText(canvas, member.guild.translate("administration/welcome:IMG_WELCOME", {
server: member.guild.name
Expand Down
11 changes: 9 additions & 2 deletions events/guildMemberRemove.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
const stringCleaner = require("@sindresorhus/slugify");
const Canvas = require("canvas"),
Discord = require("discord.js");
const { resolve } = require("path");
Expand Down Expand Up @@ -44,8 +45,14 @@ module.exports = class {
ctx.drawImage(background, 0, 0, canvas.width, canvas.height);
// Draw username
ctx.fillStyle = "#ffffff";
ctx.font = applyText(canvas, member.user.username, 48);
ctx.fillText(member.user.username, canvas.width - 660, canvas.height - 248);
const username = stringCleaner(member.user.username, {
separator: " ",
lowercase: false,
decamelize: false,
preserveLeadingUnderscore: true,
});
ctx.font = applyText(canvas, username, 48);
ctx.fillText(username, canvas.width - 660, canvas.height - 248);
// Draw server name
ctx.font = applyText(canvas, member.guild.translate("administration/goodbye:IMG_GOODBYE", {
server: member.guild.name
Expand Down

0 comments on commit 1a679cb

Please sign in to comment.