I want to print an embed item list but the empty spaces(blank field titles) between each item are bothering me and making it unnecessarily long.
So is there a way to print all the items from an array without having to keep adding new fields?
const list = new Discord.MessageEmbed()
.setTitle('Items')
.setColor('#0099ff')
for (var xc = 0; xc < (items.length-1); xc++)
{
var item = items[xc];
list.addField('\u200B',item);
}
msg.channel.send(list);
This is what I have at the moment.
Maybe set it as the description
list.setDescription(items.join("\n"));
Related
function myFunction() {
/////////////////////////////////////Fill planning/decor package
var managementSheet = SpreadsheetApp.openById("1P3EF4Edu0efzJVV1Sx-0ayAPaAAiRK8Sl0Y1qZHmcf4");
var packageSheet = managementSheet.getSheetByName("Order Contents");
//Order Contents iterater
var c = packageSheet.getMaxColumns();
var n = packageSheet.getLastRow();
var items = packageSheet.getRange(2,1,n,c).getValues();
var filteredItems = items.filter(function(row) {
if(row[2].toString().includes(firstName +" "+lastName))
{
var results =new Array();
var info = new Array();
info[0]=row[3];
info[1]=row[5];
info[2]=row[9];
info[3]=row[14];
info[4]=row[15];
info[5]=row[16];
results[0]= info;
// result = results.every().valueOf();
Logger.log(results)
var row=22
results.forEach(function(value, index) {
Logger.log("The value at index " + index + " is " + value + ".");
generatedInvoice.getRange(22,1,1,7).setValues([[info[0],,info[1],info[2],info[3],info[4],info[5]]])
row= index + 22+1
})}})
}
Hello. First off, I'm new to appscript/javascript/script in general... Secondly, I'm the worst at explaining things and am so over this as I've been working on it for 2 days with only a few food/water/sleep breaks and just can't figure it out.
I'm trying to take rows from one sheet and copy only some of that row's values to a template...
Customer orders are on one sheet.
Order CONTENTS(for all customers' orders) are on another sheet.
I want to generate an invoice containing everything that the customer has ordered. The code I have currently lists only the final row of the "results" array into my template sheet. I want all of the items that the customer ordered to be added to the invoice. I'm trying to figure out how to use "index" to move to the next line and add the next set of values, but I'm not sure what I'm doing wrong. By logging info, I see that everything is being called correctly and adding to the correct spot in the template. The problem is that it only adds the final line of data into the template when I want all of the lines that match a customer's name.
I'm pretty new to JavaScript and need to create a JSON with number of keys and values (pushed into the variable newWord), without separating them. The thing is that I don't know what would be the length it in advenced (for that I am using a for loop to push each of the keys names and values):
let langName = document.querySelectorAll('.langName');
let langInput = document.querySelectorAll('.langInput');
let newWord = new Array()
for (let i = 0; i < langName.length; i++) {
let l = langName[i].value;
let w = langInput[i].value
newWord.push({[l]: w})
}
firebase.database().ref(`content/words/`).push(
newWord
)
So, my result right now is:
While my desired result would be:
Does anyone know how do I get rid of the indexes (0, 1) and push a string key with a string value?
Edit: I want the for loop to add to the same object in this array, instead of creating a new object inside of it.
Thanks! 😁
push is used to insert in a list in firebase database. Using set, you can store as key-value objects.
let langName = document.querySelectorAll('.langName');
let langInput = document.querySelectorAll('.langInput');
let newWord = {};
for (let i = 0; i < langName.length; i++) {
let l = langName[i].value;
let w = langInput[i].value
newWord[l] = w;
}
firebase.database().ref(`content/words/`).set(
newWord
)
Thank you in advance! I'm new to coding and learning how to deal with Arrays. I am trying to remove random items from an array (deck of cards), and populate a new array (called hand). The problem I always seem to have with arrays is taking the results of one and creating a new function/array/ etc.. Currently, I am outputting 2 separate arrays and I can't seem to push them into one.
let deck = ["dA","dQ","dK","dJ","d10","d09","d08",
"d07","d06","d05","d04","d03","d02","hA","hQ","hK",
"hJ","h10","h09","h08","h07","h06","h05","h04","h03"];
var hand = deck.splice(Math.floor(Math.random()*deck.length),1);
console.log(hand)
var hand = deck.splice(Math.floor(Math.random()*deck.length),1);
console.log(hand);
In your code, just you need to push the value returned from splice method rather than directly assigning it.
By this way every time a new value that gets deleted and will be added to the new array called hand. Hope this helps. :-)
let deck = ["dA","dQ","dK","dJ","d10","d09","d08",
"d07","d06","d05","d04","d03","d02","hA","hQ","hK",
"hJ","h10","h09","h08","h07","h06","h05","h04","h03"];
var hand = [];
const getSelectedCard = () => deck.splice(Math.floor(Math.random()*deck.length),1)
let selectedCard = getSelectedCard();
hand.push(...selectedCard) //or hand.push(selectedCard[0])
console.log(hand);
selectedCard = getSelectedCard();
hand.push(...selectedCard)
console.log(hand);
I have 30 string[4] elements which contains user data. I have 30 date generic list collection. How to add each date as 5th element in each one string[] collection?
List<string> _datefromexcel = new List<string> ();
foreach(DataColumn c in dtRow.Table.Columns) {
if (Information.IsDate(c.ColumnName)) {
_datefromexcel.Add(c.ColumnName);
}
}
List<string> newlist = lst.GetRange(startrange, count);
int i = 0;
var query = from s in newlist
let num = i++
group s by num / 4 into g
select g.ToList();
var results = query.ToArray();
foreach(var item in _datefromexcel) {
results.insert(5, item);
}
This is insert all date value after 5th element.
Please advice the best way to insert each date value as 5 element in array collection.
For starters, you won't be able to "insert" anything into an array, since it has a static size. You can add things to a list, however, because a list can dynamically resize itself.
var results = query.ToList();
foreach (var item in _datefromexcel) {
results.Add(item.ToString());
}
If you need to, you can call ToArray after the foreach loop is finished:
return results.ToArray();
You can use for loop instead:
var results = query.ToArray();
for (int i = 0; i < results.Length; i++)
results[i].Add(_datefromexcel[i]);
The LINQ way will be a bit ugly:
var results = query.Zip(_datefromexcel, (l, d) => l.Concat(new[] { d }).ToList()).ToArray();
Very new to actionscript,
Im trying to link two arrays. Basically I have a word array of 8 words and I have a movie clip array of 8 movieclips. My aim is to link the two arrays so that the user must click the right movie clip that matches the word that was displayed on screen.
All help is greatly appreciated!!
var listAry:Array = [];
var orangeJuice:Object = new Object();
orangeJuice.name= "Orange Juice";
orangeJuice.matchingImage=oj;
listAry[0]=orangeJuice;
////etc etc
There you go buddy. Hope that helps if you have any questions just ask.
Another way to do this is with a Dictionary.
var foodionary:Dictionary = new Dictionary();
foodionary["Orange Juice"] = oj;
foodionary["Sandwich"] = sand;
//etc...
for(var key:String in foodionary) {
trace(key + " matches with " + foodionary[key].id); //assuming your images have ids
}
For random access, though, you'll still need an array (or a Vector):
function displayword(){
randomnumber = Math.floor(Math.random() * randomlistword.length);
trace("random number = " + randomnumber);
var chosenword = randomlistword[randomnumber];
randomword.text = chosenword
randomword.img = foodionary[chosenword];
randomlistword.splice(randomnumber, 1);
trace("randomlistword array: " + randomlistword);
}//close displayword function