From 6ed02de8dcfae6003a340210ba09830c0b459ccc Mon Sep 17 00:00:00 2001 From: = Date: Sat, 31 Jul 2021 19:41:38 -0400 Subject: [PATCH] add icons to pastas --- commands/pasta.js | 4 +++- functions.js | 13 +++++++++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/commands/pasta.js b/commands/pasta.js index 5c955e0..9276108 100644 --- a/commands/pasta.js +++ b/commands/pasta.js @@ -8,11 +8,13 @@ module.exports = { const client = message.client; const replyHeader = `\'${file.name}\' requested by: ${message.author.username}\n`; let replyBody = ''; + let iconUrl; if (!client.pastas.has(file.name)) { replyBody = 'Sorry I couldn\'t find that pasta.'; } else { replyBody = client.pastas.get(file.name).content; + iconUrl = client.pastas.get(file.name).iconUrl; } - message.channel.send(functions.textEmbed(replyBody, message.author, `${file.name}.${file.extension}`)); + message.channel.send(functions.pastaEmbed(replyBody, iconUrl, message.author)); } } \ No newline at end of file diff --git a/functions.js b/functions.js index ee23b3d..6d43a74 100644 --- a/functions.js +++ b/functions.js @@ -65,14 +65,15 @@ module.exports = { getPastaFiles(client) { if (!client.pastas) client.pastas = new Discord.Collection(); client.pastas.clear(); - const query = "SELECT name, content FROM pastas"; + const query = "SELECT name, content, iconurl FROM pastas"; return new Promise((resolve, reject) => { db.query(query) .then(res => { for (let row of res.rows) { const pasta = { name: row.name, - content: row.content + content: row.content, + iconUrl: row.iconurl }; client.pastas.set(pasta.name, pasta); } @@ -172,6 +173,14 @@ module.exports = { .setTimestamp() .setFooter(`@${author.username}#${author.discriminator}`); }, + pastaEmbed(content, iconUrl, author) { + return new Discord.MessageEmbed() + .setAuthor('Command: ' + 'pasta') + .setDescription(content) + .setThumbnail(iconUrl) + .setTimestamp() + .setFooter(`@${author.username}#${author.discriminator}`); + }, createStockEmbed(data, author, command) { return new Discord.MessageEmbed() .setAuthor('Command: ' + command)