Squiso is a free, powerful automation tool that lets you customize your Twitch stream using simple scripts.
How to Automatically Post New Twitch Clips to Discord
This examples checks for new clips every 10 minutes and if there are any new clips created by a specific user, then post it to a Discord server.
Script Example
import com.squiso.*;
import com.squiso.exception.*;
import com.squiso.scripting.*;
import com.squiso.scripting.data.*;
import com.squiso.keyboard.*;
import com.squiso.twitch.*;
import com.squiso.datatypes.*;
import com.squiso.utils.*;
// Important - Please do not change the row below - otherwise you will get a compilation error!
public class Script_Example extends SquisoScript {
@Override
public void onEveryMinute(OnEveryMinuteData data, API api) throws SquisoException {
// Do this every 10 minutes
if (data.is(10)) {
// Save the time right now
SquisoDate now = SquisoDate.nowUTC();
api.log("[Example_AutomaticallyPostTwitchClipsDiscord] Time now is: " + now.toYYYYMMDDHHMMSS());
// Get all the 100 latest clips
SquisoList<TwitchClip> allClips = api.getTwitchClips();
api.log("[Example_AutomaticallyPostTwitchClipsDiscord] Found " + allClips.size() + " clips");
for (TwitchClip clip : allClips) {
// If the creator is not "Squiso", then skip and continue to the next clip
if (!clip.getCreator().equalsIgnoreCase("Squiso")) {
continue;
}
// Get the number of seconds since the clip was created from now
SquisoInteger secondsSinceCreated = clip.getCreated().getSecondsSince(now);
api.log("[Example_AutomaticallyPostTwitchClipsDiscord] The clip \"" + clip.getTitle() + "\" was created " + secondsSinceCreated + " seconds ago (" + clip.getCreated().toYYYYMMDDHHMMSS() + ") by \"" + clip.getCreator() + "\".");
// 10 minutes is 10*60=600 seconds
SquisoInteger threshold = new SquisoInteger(60 * 10);
// Just log the check
api.log("[Example_AutomaticallyPostTwitchClipsDiscord] Checking if clip is below the threshold (" + secondsSinceCreated + " < " + threshold + ")....");
// If the clip was created in the last 10 minutes
if (secondsSinceCreated.isLessThan(threshold.get())) {
api.log("[Example_AutomaticallyPostTwitchClipsDiscord] Posting clip \"" + clip.getTitle() + "\" to Discord");
// Compose a Discord message
SquisoString discordMessage = new SquisoString("");
discordMessage.append("A new clip was created by " + clip.getCreator() + "!");
discordMessage.append("\n");
discordMessage.append(clip.getURL());
// Send the message to the Discord channel
SquisoString discordWebhook = new SquisoString("https://discord.com/api/webhooks/abc/123");
api.sendSimpleDiscordMessage(discordWebhook, discordMessage);
}
}
}
}
}