This script will notify you of changes to your google sheet through discord, using a customizable discord embed.
- Go to the script editor on your google sheet
- Paste the contents of the
main.gs
file into the script editor - Open Discord, go to 'Server Settings' > 'Integrations' > 'Webhooks'
- Create a 'New Webhook' & fill in all the fields necessary.
- Copy the webhook link & paste this link into the "WEBHOOKURL".
- In the google sheet script editor, using the left hand side menu, navigate to 'Triggers' and add a new trigger as shown in the image below
Make sure to edit a range to test it.
This section will showcase different options that you can implement to customize your embeds and program behaviour.
With the addition of Discord's new Forum channels, there is the ability to direct your google form responses into individual threads or the same singular thread!
thread_name
can be used to specify the name of the thread you want to generate.
{
"thread_name" : "THREAD TITLE GOES HERE",
"embeds" :[{
"title": "TOP TEXT CHANGE THIS IN SCRIPT",
"fields" : items,
"color": 16711680
}]
}
thread_id
can be used to specify the thread you want all responses to go into.
{
"thread_id" : 1234 //Your thread id goes here! ,
"embeds" :[{
"title": "TOP TEXT CHANGE THIS IN SCRIPT",
"fields" : items,
"color": 16711680
}]
}
This addition will allow you to only be notified if edits are made in the specified column. This code should be pasted after the var items = [];
line.
// If you only want to watch a certain column
var column_id = 3
// If not the column you want to watch
if (column_id < event.range.getColumn() || column_id > event.range.getLastColumn() ){
// Do nothing
return;
}
In this section, we will outline the multiple different cosmetic customizations that you can add to your webhook. You can use any combination of the options displayed below.
This option will allow you to set a colour to your embed. The colour option requires a numerical input instead of hexadecimal. E.g. Red in Hexadecimal is #FF0000. As a decimal, this would be translated into 16711680.
{
"embeds" :[{
"title": "TOP TEXT CHANGE THIS IN SCRIPT",
"fields" : items,
"color": 16711680
}]
}
This option adds an author block to the embed. The author block (object) includes three values:
- name - the name field.
- url - allows for a hyperlink to be attached to the name.
- icon_url - avatar displayed.
{
"embeds" :[{
"title": "TOP TEXT CHANGE THIS IN SCRIPT",
"fields": items,
"author": {
"name": "AUTHOR NAME CHANGE THIS IN SCRIPT",
"url": "URL CHANGE THIS IN SCRIPT",
"icon_url": "ICON URL CHANGE THIS IN SCRIPT"
}
}]
}
This option binds a url link to the title of your embed.
{
"embeds" :[{
"title": "TOP TEXT CHANGE THIS IN SCRIPT",
"fields": items,
"url": "URL CHANGE THIS IN SCRIPT"
}]
}
Displays a description for the embed.
{
"embeds" :[{
"title": "TOP TEXT CHANGE THIS IN SCRIPT",
"fields": items,
"description": "DESCRIPTION CHANGE THIS IN SCRIPT"
}]
}
Displays an image inside of the embed.
{
"embeds" :[{
"title": "TOP TEXT CHANGE THIS IN SCRIPT",
"fields": items,
"image": {
"url": "URL CHANGE THIS IN SCRIPT"
}
}]
}
Allows for a thumbnail to be displayed in the embed.
{
"embeds" :[{
"title": "TOP TEXT CHANGE THIS IN SCRIPT",
"fields": items,
"thumbnail": {
"url": "URL CHANGE THIS IN SCRIPT"
}
}]
}
An optional customization you can make to footer text, is to add an icon image which will be displayed next to it.
{
"embeds" :[{
"title": "TOP TEXT CHANGE THIS IN SCRIPT",
"fields": items,
"footer": {
"text": "BOTTOM TEXT CHANGE THIS IN SCRIPT",
"icon_url": "URL CHANGE THIS IN SCRIPT"
}
}]
}