not really sure what's going on with this code.. At one point, the code was working fine. Woke up the next day and it completely stopped working. Im not sure if something was updated, but its just weird. JavaScript isn't my strongest language
Does anyone have any ideas? Me and 3 others have been stumped for a few days on this. Thanks for any help!
const { SlashCommandBuilder } = require('@discordjs/builders');
const { MessageEmbed } = require('discord.js');
const { QuickDB } = require('quick.db');
const db = new QuickDB();
onst config = require('../Database/config.json');
module.exports = {
data: new SlashCommandBuilder()
.setName('farm')
.setDescription('Join servers for coins!'),
async execute(interaction, client) {
await interaction.deferReply();
let orders = await db.all(`orders_`, { sort: ".data" })
let length = 0;
orders = orders.filter(x => x.data > 0 && client.guilds.cache.get(x.ID.split("_")[1])
&& client.guilds.cache.get(x.ID.split("_")[1]).members.cache.get(interaction.user.id) ===
undefined)
const embed = new MessageEmbed()
.setColor("RANDOM")
.setTitle('Farm!')
for (let i = 0; i < orders.length; i ) {
let handler = true
console.log(orders)
if (length >= 1) { return; } else {
let id = orders[i].ID.split("_")[1]
let guild = client.guilds.cache.get(orders[i].ID.split("_")[1]).name
let code = await db.get(`code_${id}`)
await client.fetchInvite("https://discord.gg/" code)
.then(link => {
console.log(link.code)
if (link.code === null) handler = false
})
.catch(error => {
handler = false
})
await new Promise(resolve => setTimeout(resolve, 1))
if (handler) {
let description = await db.get(`description_${id}`)
embed.setDescription(`${guild} - ${description}`,)
length
}
}
}
interaction.editReply({ embeds: [embed] });
},
};
CodePudding user response:
It's possibly a typo in line 5:
onst config = require('../Database/config.json');
should be
const config = require('../Database/config.json');
CodePudding user response:
To create a link on embed:
const embed = new MessageEmbed()
.setDescription('[Testing Link](https://www.google.com/)') //Your HyperLink
message.channel.send({embeds: [embed]})
These should be your code looks like:
embed.setDescription(`[${guild}] - (${description})`)
const guild = "Something Testing for a link";
const description = "https://www.google.com/";
const embed = new MessageEmbed()
.setDescription(`[${guild}](${description})`)
message.channel.send({embeds: [embed]})
Remember to start your Hyperlink with https://
or http://