#stocknames
1 messages · Page 1 of 1 (latest)
thats actually better
(yay threads are noice)
indeed
well, you said
for(idk)
idk
stuff
}```
I understand that it creates a variable called stock for each stockname
Yes
but why is there a for in the for loop
Oh that
how should I use it correctly?
so I should add that there?
yea, makes sense
since I have a substock for my stock
ah, the forloop just replaces forEach?
so I can just put the whole code into there?
Oh btw, pasting the code instead of screening it makes it easier :p ||I say as I literally came here with a screenshot of my code for my problem||
Yeah it's more readable imo - you don't need to, but I'd say it's good practice
I see, thats very good to know
aight, time to abuse nitro
const path = require("path")
const fs = require("fs");
const Discord = require('discord.js');
const StockBlog = require("../../schemas/StockSchema");
module.exports = {
name: "stocklist",
category: "stocks",
permissions: [],
devOnly: false,
description: "Shows all Stocks or one specific in a list",
usage: "stocklist [stock]",
run: async ({bot, message, args}) => {
let { client } = bot;
const embed = new Discord.MessageEmbed()
const dir = path.join(__dirname, "../../Stockimages")
let fullstocknames = fs.readdirSync(dir)
let stocknames = fullstocknames.map(d => d.slice(0, -4))
embed.setTitle(`Stock List`)
//.setImage(message.guild.iconURL())
/*fullstocknames.forEach((stock) => {
const attachment = new Discord.MessageAttachment(`Stockimages/${stock}`, stock)
embed.setTitle('test')
.setImage(`attachment://${stock}`)
message.channel.send({ embeds: [embed], files: [attachment] })
})*/
if(args[0] === undefined) {
for(let stock of stocknames) {
for()
}
/*stocknames.forEach((stock) => {
const stockasync = async() => {
for(let i = 1;i < 6;i++) {
let stocknumberfetch = await StockBlog.findOne({StockName: stock, StockNumber: i}, "StockName Owner StockValue StockNumber").exec()
console.log(stocknumberfetch)
//embed.addField({ name: `***${stocknumberfetch.StockName}*** ${stocknumberfetch.StockNumber}`, value: `${stocknumberfetch.Owner}: ***$${stocknumberfetch.StockValue}***` })
}
}
stockasync()
})
message.channel.send({ embeds: [embed] })*/
} else if (stocknames.includes(args[0])) {
} else throw "?Not a valid Stockname"
}
}
Ok back to square 1
says that my MessageEmbed is an empty String, even tho it clearly isnt
What version of discord.js are you using?
uh
Because in the last version, this is the prototype of addField
16.14
... Did you spit out your node.js version? xD
discord.js's last version is 13.7
In your package.json file
Yeah, still the same prototype
https://discord.js.org/#/docs/discord.js/13.6.0/class/MessageEmbed?scrollTo=addField
indeed
Great, you have access to modals now lol (but yeah that's your error)
modals?
well, if it doesnt break my code, I am fine with it
as long as it runs its fine xD
a problem with the Field
ig
This 
So yeah you have to write embed.addField('vv', 'a') instead
It takes 2 parameters, not an object
Why do you put curly braces? They're only used for objects
You haven't made your way through JS syntax yet have you x')
cause it needs to be done...?
No it doesn't
I just started out 2 years ago like swimming in an open ocean for the first time
xD
You write it like this
What does it say?
And what did you write
Seems to me like the field is being added to the embed
seems like its being an ass 
What's not working exactly?

thanks, well its legal so its fine
The background? Because Betterdiscord technically breaks Discord's TOS (even though in my experience they don't care about it)
