bug resolution with welcome message example
This commit is contained in:
parent
93ac8b1029
commit
a02979522f
3 changed files with 19 additions and 12 deletions
|
@ -8,6 +8,7 @@ export default {
|
|||
.setName("welcomeexample")
|
||||
.setDescription("Send an example of the welcome message of the server."),
|
||||
async execute(interaction: CommandInteraction) {
|
||||
await interaction.deferReply()
|
||||
const connection = await connectToDb();
|
||||
|
||||
const guild_id = interaction.guild?.id ? interaction.guild?.id : ""
|
||||
|
@ -17,7 +18,7 @@ export default {
|
|||
if (!guild[0]) {
|
||||
const embed = errorEmbed("Your server must be registered to the bot, use /register to do so.", interaction.client.user.displayAvatarURL());
|
||||
|
||||
return interaction.reply({embeds: [embed]});
|
||||
return interaction.editReply({embeds: [embed]});
|
||||
}
|
||||
|
||||
const member = interaction.guild?.members.cache.get(interaction.user.id)
|
||||
|
@ -25,7 +26,7 @@ export default {
|
|||
if (!member?.permissions.has(PermissionFlagsBits.Administrator) && !member?.roles.cache.has(guild[0].admin_role_id)) {
|
||||
const embed = errorEmbed("You are not allowed to use that command.", interaction.client.user.displayAvatarURL());
|
||||
|
||||
return await interaction.reply({embeds: [embed]});
|
||||
return await interaction.editReply({embeds: [embed]});
|
||||
}
|
||||
|
||||
const config = await getWelcomeConfig(connection, guild_id);
|
||||
|
@ -35,7 +36,7 @@ export default {
|
|||
if (!config[0]) {
|
||||
const embed = errorEmbed("Your welcome message must be setup before using that command.", interaction.client.user.displayAvatarURL());
|
||||
|
||||
return interaction.reply({embeds: [embed]});
|
||||
return interaction.editReply({embeds: [embed]});
|
||||
}
|
||||
|
||||
const embed = new EmbedBuilder();
|
||||
|
@ -52,17 +53,18 @@ export default {
|
|||
embed.setThumbnail(config[0].vignette_url);
|
||||
}
|
||||
|
||||
var attachement;
|
||||
var buffer;
|
||||
var files = [];
|
||||
|
||||
if (config[0].background_url) {
|
||||
buffer = await createWelcomeImage(config[0].background_url, `https://cdn.discordapp.com/avatars/${interaction.user.id}/${interaction.user.avatar}.jpeg`, interaction.user.id);
|
||||
attachement = new AttachmentBuilder(buffer, { name: `${interaction.user.id}.png` })
|
||||
files.push(attachement)
|
||||
embed.setImage(`attachment://${interaction.user.id}.png`)
|
||||
const buffer = await createWelcomeImage(config[0].background_url, `https://cdn.discordapp.com/avatars/${interaction.user.id}/${interaction.user.avatar}.jpeg`, interaction.user.id);
|
||||
|
||||
if (buffer) {
|
||||
const attachement = new AttachmentBuilder(buffer, { name: `${interaction.user.id}.png` })
|
||||
files.push(attachement)
|
||||
embed.setImage(`attachment://${interaction.user.id}.png`)
|
||||
}
|
||||
}
|
||||
|
||||
interaction.reply({content: config[0].message_format ? config[0].message_format.replace("{user}", `<@${interaction.user.id}>`).replace("{welcomer}", `<@&${config[0].welcomer_role_id ? config[0].welcomer_role_id : ""}>`) : "", embeds: [embed], files: files});
|
||||
interaction.editReply({content: config[0].message_format ? config[0].message_format.replace("{user}", `<@${interaction.user.id}>`).replace("{welcomer}", `<@&${config[0].welcomer_role_id ? config[0].welcomer_role_id : ""}>`) : "", embeds: [embed], files: files});
|
||||
},
|
||||
};
|
||||
|
|
|
@ -1,8 +1,14 @@
|
|||
import { createCanvas, loadImage } from 'canvas';
|
||||
import { BufferResolvable } from 'discord.js';
|
||||
import * as fs from "node:fs";
|
||||
|
||||
export async function createWelcomeImage(background_url: string, icon_url: string, user_id: string) {
|
||||
export async function createWelcomeImage(background_url: string, icon_url: string, user_id: string) : Promise<Buffer | undefined> {
|
||||
const background = await loadImage(background_url)
|
||||
|
||||
if (!background) {
|
||||
return;
|
||||
}
|
||||
|
||||
const icon = await loadImage(icon_url)
|
||||
|
||||
var width;
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
"module": "NodeNext",
|
||||
"moduleResolution": "NodeNext",
|
||||
"resolveJsonModule": true,
|
||||
"strict": true,
|
||||
"outDir": "./dist",
|
||||
"skipLibCheck": true,
|
||||
"noImplicitAny": true,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue