I've got this code to send the message, but I know that there has to be a more efficient way to do so, rather than a new message for every section. Trying it that way is overloading the webhook and causing me to be rate limited.
I've edited to include the full code, minus the webhook URLs. I'm fairly new to coding, so I'm sure it's a mess, but I know it was at least working up to a point because I was testing as I went. It's mainly the sending back part that isn't working how I intended.
function Insert_Checks() {
const ss = SpreadsheetApp.getActiveSpreadsheet()
var ws = ss.getActiveSheet()
var range = ws.getRange(2,2,ws.getLastRow() - 1)
var rangec = range.offset(0,1)
rangec.insertCheckboxes()
}
function Supply_Order_Complete() {
const ss = SpreadsheetApp.getActiveSpreadsheet()
var ws = ss.getActiveSheet()
var range = ws.getRange(2,1,ws.getLastRow())
num_rows = Logger.log(range.getNumRows())
const rows = ws.getDataRange().getValues()
var headers = rows.shift();
var ordered = []
var subs = []
var notes = []
rows.forEach(function(row) {
i = 0
if(row[2] || row[4] != "") {
ordered.push(row[1].getValue)
subs.push(row[3].getValue)
notes.push(row[4].getValue)
}
while (i <= ordered.length) {
var currentMessage = []
currentMessage.push("'ordered[i]' - 'subs[i]' - 'notes[i]'\n")
i = i + 1
}
Send_Order(currentMessage)
});
}
function Send_Order(currentMessage) {
const ss = SpreadsheetApp.getActiveSpreadsheet()
var ws = ss.getActiveSheet()
var wsn = ws.getName()
if (wsn === "9th") {
url =
}
if (wsn === "Apartments") {
url =
}
if (wsn === "Billings") {
url =
}
if (wsn === "ElmA") {
url =
}
if (wsn === "ElmB") {
url =
}
if (wsn === "Knollview") {
url =
}
if (wsn === "Centennial") {
url = '
}
if (wsn === "Michigan") {
url =
}
if (wsn === "Scammon") {
url =
}
if (wsn === "Adams") {
url =
}
if (wsn === "Test") {
url =
}
const message = {
content: currentMessage
}
const options = {
'method' : 'post',
'payload' : message
}
const res = UrlFetchApp.fetch(url,options)
}```
What I am getting on Discord is this:
[Ljava.lang.Object;@2eced131
[Ljava.lang.Object;@5b8e5a90
[Ljava.lang.Object;@1b09921c
[Ljava.lang.Object;@4037c438
[Ljava.lang.Object;@24727d3e
Each one being a separate message rather than one message.
[![enter image description here][1]][1]
[1]: https://i.stack.imgur.com/FmWJH.png