add icons to pastas

This commit is contained in:
= 2021-07-31 19:41:38 -04:00
parent 1d9d3e0750
commit 6ed02de8dc
2 changed files with 14 additions and 3 deletions

View File

@ -8,11 +8,13 @@ module.exports = {
const client = message.client; const client = message.client;
const replyHeader = `\'${file.name}\' requested by: ${message.author.username}\n`; const replyHeader = `\'${file.name}\' requested by: ${message.author.username}\n`;
let replyBody = ''; let replyBody = '';
let iconUrl;
if (!client.pastas.has(file.name)) { if (!client.pastas.has(file.name)) {
replyBody = 'Sorry I couldn\'t find that pasta.'; replyBody = 'Sorry I couldn\'t find that pasta.';
} else { } else {
replyBody = client.pastas.get(file.name).content; 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));
} }
} }

View File

@ -65,14 +65,15 @@ module.exports = {
getPastaFiles(client) { getPastaFiles(client) {
if (!client.pastas) client.pastas = new Discord.Collection(); if (!client.pastas) client.pastas = new Discord.Collection();
client.pastas.clear(); client.pastas.clear();
const query = "SELECT name, content FROM pastas"; const query = "SELECT name, content, iconurl FROM pastas";
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
db.query(query) db.query(query)
.then(res => { .then(res => {
for (let row of res.rows) { for (let row of res.rows) {
const pasta = { const pasta = {
name: row.name, name: row.name,
content: row.content content: row.content,
iconUrl: row.iconurl
}; };
client.pastas.set(pasta.name, pasta); client.pastas.set(pasta.name, pasta);
} }
@ -172,6 +173,14 @@ module.exports = {
.setTimestamp() .setTimestamp()
.setFooter(`@${author.username}#${author.discriminator}`); .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) { createStockEmbed(data, author, command) {
return new Discord.MessageEmbed() return new Discord.MessageEmbed()
.setAuthor('Command: ' + command) .setAuthor('Command: ' + command)