Hey guys, withy code right here, from line around !live command (last lines of code), when i use the command, my code just sends me duplicated if the objects in the json file, I made sure the json file is perfect, so the problem is the code, can anyone help.
import { discordSort, messageLink } from "discord.js";
import { Client, GatewayIntentBits, EmbedBuilder, SlashCommandBuilder } from "discord.js"
const client = new Client(
{
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.GuildMembers,
GatewayIntentBits.MessageContent
]
}
)
var liveEmbed;
// @ts-ignore
import IFL from "iflive"
// @ts-ignore
IFL.init('hidden', {"enableLog": true, "loggingLevel": 1, "callback": true});
// embeds
const ranksEmbed = new EmbedBuilder()
.setColor('#E0050B')
const siteEmbed = new EmbedBuilder()
.setColor('#E0050B')
.setTitle('Avianca Virtual Website')
.setURL('https://ifaviancavirtual.com')
.setAuthor({ name: 'Avianca Virtual', iconURL: 'https://media.discordapp.net/attachments/948687532365869108/995388756301463552/761D13FB-12BE-4FA6-A53D-9335196D5469.jpg', url: 'https://discord.js.org' })
.setFooter({ text: 'Generated by the Avianca Virtual Official Assistant Bot'});
const ccEmbed = new EmbedBuilder()
.setColor('#E0050B')
const routesEmbed = new EmbedBuilder()
const multipliersEmbed = new EmbedBuilder()
.setColor('#E0050B')
const helpEmbed = new EmbedBuilder()
.setColor('#E0050B')
// @ts-ignore
// @ts-ignore
const channel = client.channels.cache.find(channel => channel.name === "general");
client.on("ready", () => {
console.log(`Logged in as ${client.user.tag}!`)
})
// create channel when member joins
// welcome message in general
// commands
msg.reply({ embeds: [ticketEmbed] });
} else if (msg.content.startsWith(prefix) && msg.content.includes("please")) {
msg.reply("Please?");
}
})
client.on('messageCreate', msg => {
if (msg.content.startsWith(prefix) && msg.content.includes("userStats")) {
const name = msg.content.slice("!userStats".length).trim().split(' ');
IFL.call("users", {}, {discourseNames: name}, (data) => {
const flightTime = data[0].flightTime/60
const hours = flightTime.toFixed(0)
const statsEmbed = new EmbedBuilder()
.setColor('#E0050B')
.setTitle('Here are the ranks for ' + "**" + name + "**")
msg.reply({ embeds: [statsEmbed] })
})}})
IFL.call("flights", { sessionId: "7e5dcd44-1fb5-49cc-bc2c-a9aab1f6a856" }, {});
// @ts-ignore
IFL.call("sessions", {}, {}, (seshData) => {
})
client.on("messageCreate", msg => {
if (msg.content.startsWith(prefix) && msg.content.includes("live")) {
IFL.call("sessions", {}, {}, (sessionData) => {
IFL.call("flights", {sessionId: "7e5dcd44-1fb5-49cc-bc2c-a9aab1f6a856"}, {}, (data) => {
msg.channel.send("Here are the pilots that are flying at this moment:")
for(var i=0 ; i < data.length ; i++ ){
var last2 = (data[i].callsign?.slice(-2).toString())
// @ts-ignore
if (last2 === "AK") {
liveEmbed = new EmbedBuilder()
.setTitle("Flights:")
.setAuthor({ name: "callsign", iconURL: 'https://media.discordapp.net/attachments/948687532365869108/995388756301463552/761D13FB-12BE-4FA6-A53D-9335196D5469.jpg', url: 'https://discord.js.org' })
.setColor('#E0050B')
.addFields(
{name: "Username:", value: data[i].username},
{name: "Callsign:", value: data[i].callsign},
{name: "Altitude:", value: data[i].altitude.toFixed(0) + "ft"},
{name: "Speed:", value: data[i].speed.toFixed(0) + "kts"}
)
}
msg.channel.send({ embeds: [liveEmbed] });
}
}
)
})
}
})
client.login("hidden")