[Response must be less than 400 characters] with google sheets

Hi guys,
I saw a streamer who has a count of matches for tournaments For example when someone types !match it comes up with Match 3/6 solo cash cup :FortOne :FortOne . And if a mod types !m Match 4/6 solo cash cup it update !match to say Match 4/6 solo cash cup :FortOne :FortOne . But when i tried to replicate this !m kept on coming back that the response must be less than 400 characters.
I am trying to do this via google sheets and a script. This is the script for the google sheets:

function storeData(key, value) {
var sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
var lastRow = sheet.getLastRow() + 1;

sheet.getRange(lastRow, 1).setValue(key);
sheet.getRange(lastRow, 2).setValue(value);

return "Data stored successfully for key: " + key;
}

function getData(key) {
var sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
var data = sheet.getDataRange().getValues();

for (var i = 1; i < data.length; i++) {
if (data[i][0] === key) {
return "Value for " + key + ": " + data[i][1];
}
}

return "Key not found: " + key;
}

The command I entered in to nb for !m which is the storeData function is

$(urlfetch script for google https adresss cant add link/macros/s/AKfycbzgp7WGxYP_cP4JZpAK3l5EgLM62ic7WQPw7PJyHR_SgoA4ax5rHoEKml4UaG9R-0DH1Q/exec?command=storeData&key=$(querystring $(1))&value=$(querystring $(2)))

And for the !match which is the getData function is

$(urlfetch script for google https adresss cant add link/macros/s/AKfycbwlnGVixgMxpJ_ZoJoPbE8NKfjOVb-wozAA75w5l9rTQn5xya5nfGtgvObCYWnpSNdcmA/exec?command=getData&key=$(querystring $(1)))

I hope someone can help me,
Thank you

Could really do with seeing the full code for the commands. If “script for google https adress cant add” means this page won’t put the code in, click the </> button to enter raw code. Same with your script would probably be helpful too !

Like this?

$(urlfetch </Error(querystring $(1))&value=$(querystring $(2))>)

No. When you type on a reply, there is a button with </> on it.

image

image

Oh i see sry i dont have button on my phone ill have a look later on my pc

1 Like

When you do…

it will appear like this on your post !

:slight_smile:

1 Like
$(urlfetch https://script.google.com/link/macros/s/AKfycbzgp7WGxYP_cP4JZpAK3l5EgLM62ic7WQPw7PJyHR_SgoA4ax5rHoEKml4UaG9R-0DH1Q/exec?command=storeData&key=$(querystring $(1))&value=$(querystring $(2)))
$(urlfetch http://script.google.com/link/macros/s/AKfycbwlnGVixgMxpJ_ZoJoPbE8NKfjOVb-wozAA75w5l9rTQn5xya5nfGtgvObCYWnpSNdcmA/exec?command=getData&key=$(querystring $(1)))
function storeData(key, value) {
var sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
var lastRow = sheet.getLastRow() + 1;

sheet.getRange(lastRow, 1).setValue(key);
sheet.getRange(lastRow, 2).setValue(value);

return "Data stored successfully for key: " + key;
}

function getData(key) {
var sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
var data = sheet.getDataRange().getValues();

for (var i = 1; i < data.length; i++) {
if (data[i][0] === key) {
return "Value for " + key + ": " + data[i][1];
}
}

return "Key not found: " + key;
}

Like that?

May I try your command to see what it is replying with ? @CoolKatTTV

Sure what info do u need?

Better still - Try this - In a browser put your http link line with valid data and see what the response is. If the response is more than 400 chars then that is your problem. Remember to look at the source code for the page if it displays a page. If it replies with an actual web page rather than just a short text string, then that is most likely your problem.

i.e.

https://script.google.com/link/macros/s/AKfycbzgp7WGxYP_cP4JZpAK3l5EgLM62ic7WQPw7PJyHR_SgoA4ax5rHoEKml4UaG9R-0DH1Q/exec?command=storeData&key=[valid data here]&value=[valid data here]

Thanks I’ll try that

Actually your original question has been answered :slight_smile: See https://community.nightdev.com/t/custom-edit-command/35219/5?u=zoeballz

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.