Merge new rendering into master #60
1
.gitignore
vendored
1
.gitignore
vendored
@@ -6,6 +6,7 @@
|
||||
assets/image_cache
|
||||
assets/cards
|
||||
assets/import
|
||||
assets/userdata
|
||||
|
||||
### Visual Studio Code ###
|
||||
.vscode
|
||||
|
||||
0
assets/userdata/profiles/.gitkeep
Normal file
0
assets/userdata/profiles/.gitkeep
Normal file
@@ -1,6 +1,6 @@
|
||||
const { SlashCommandBuilder, ComponentType, TextInputBuilder, TextInputStyle, ActionRowBuilder, ButtonBuilder, ButtonStyle, ModalBuilder } = require("discord.js");
|
||||
const { SlashCommandBuilder, ComponentType, TextInputBuilder, TextInputStyle, ActionRowBuilder, ButtonBuilder, ButtonStyle, ModalBuilder, Attachment } = require("discord.js");
|
||||
const { Card, User, Character } = require("../models");
|
||||
const { UserUtils, ReplyUtils } = require("../util");
|
||||
const { UserUtils, ReplyUtils, GeneralUtils } = require("../util");
|
||||
|
||||
const pageSize = 8;
|
||||
|
||||
@@ -8,12 +8,18 @@ const pageSize = 8;
|
||||
module.exports = {
|
||||
data: new SlashCommandBuilder()
|
||||
.setName("editprofile")
|
||||
.setDescription("Edit your profile"),
|
||||
.setDescription("Edit your profile")
|
||||
.addAttachmentOption((option) =>
|
||||
option
|
||||
.setName("attachement")
|
||||
.setDescription("Attachement to be used")
|
||||
.setRequired(false)
|
||||
),
|
||||
permissionLevel: 0,
|
||||
async execute(interaction) {
|
||||
await interaction.deferReply();
|
||||
let user = await UserUtils.getUserByDiscordId(interaction.member.id);
|
||||
|
||||
let patreon = await UserUtils.getPatreonPerks(interaction.client, user);
|
||||
let profile = await user.getProfile();
|
||||
|
||||
|
||||
@@ -31,6 +37,15 @@ module.exports = {
|
||||
.setStyle(ButtonStyle.Primary)
|
||||
);
|
||||
|
||||
if (patreon.perks?.["custom_bg"] === true && interaction.options.getAttachment("attachement")) {
|
||||
mainRow.addComponents(
|
||||
new ButtonBuilder()
|
||||
.setLabel('Set attachment as custom background')
|
||||
.setCustomId('setCustomBg')
|
||||
.setStyle(ButtonStyle.Primary)
|
||||
);
|
||||
}
|
||||
|
||||
const pingRow = new ActionRowBuilder();
|
||||
pingRow.addComponents(
|
||||
new ButtonBuilder()
|
||||
@@ -62,6 +77,19 @@ module.exports = {
|
||||
case 'editShowcase':
|
||||
await this.openShowcaseModal(i, user, profile);
|
||||
break;
|
||||
case 'setCustomBg':
|
||||
await i.deferReply();
|
||||
let allowedContentTypes = [ "image/png", "image/jpeg" ];
|
||||
let image = interaction.options.getAttachment("attachement");
|
||||
if (!allowedContentTypes.includes(image.contentType)) {
|
||||
await i.editReply({ content: "An invalid image has been attached. Allowed are .png and .jpeg", ephemeral: true });
|
||||
return;
|
||||
}
|
||||
await GeneralUtils.downloadFile(image.url, `/app/assets/userdata/profiles/${image.id}_${image.name}`);
|
||||
profile.customBackground = `${process.env.ASSET_URL}/userdata/profiles/${image.id}_${image.name}`;
|
||||
await profile.save();
|
||||
await i.editReply('Custom profile background has been set!');
|
||||
break;
|
||||
case 'toggle-wishlist-ping':
|
||||
await i.deferUpdate();
|
||||
user.wishlistPing = !user.wishlistPing;
|
||||
|
||||
@@ -24,7 +24,7 @@ module.exports = {
|
||||
|
||||
let discordUser = interaction.options.getUser("user") ? interaction.options.getUser("user") : interaction.member.user;
|
||||
let user = await UserUtils.getUserByDiscordId(discordUser.id);
|
||||
|
||||
let patreon = await UserUtils.getPatreonPerks(interaction.client, user);
|
||||
let profile = await user.getProfile();
|
||||
|
||||
let customStatus = profile.customStatus;
|
||||
@@ -154,6 +154,18 @@ module.exports = {
|
||||
]
|
||||
}
|
||||
|
||||
if (patreon.perks?.['custom_bg'] && profile.customBackground) {
|
||||
job.elements.unshift(
|
||||
{
|
||||
"type": "image",
|
||||
"asset": profile.customBackground,
|
||||
"x": 0,
|
||||
"y": 0,
|
||||
"width": 1200,
|
||||
"height": 600
|
||||
}
|
||||
);
|
||||
}
|
||||
console.log("Fetching ", );
|
||||
if(process.env.NODE_ENV === "development") {
|
||||
await interaction.channel.send(`\`\`\`${JSON.stringify(job)}\`\`\``);
|
||||
|
||||
@@ -101,7 +101,8 @@ const PATREON = {
|
||||
wishlist: 15,
|
||||
currency: 1.25,
|
||||
daily: 1.5
|
||||
}
|
||||
},
|
||||
custom_bg: true
|
||||
},
|
||||
4 : {
|
||||
modifiers: {
|
||||
@@ -110,7 +111,8 @@ const PATREON = {
|
||||
wishlist: 25,
|
||||
currency: 1.75,
|
||||
daily: 2
|
||||
}
|
||||
},
|
||||
custom_bg: true
|
||||
},
|
||||
5 : {
|
||||
modifiers: {
|
||||
@@ -119,7 +121,8 @@ const PATREON = {
|
||||
wishlist: 45,
|
||||
currency: 2,
|
||||
daily: 4
|
||||
}
|
||||
},
|
||||
custom_bg: true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user