Add words or phrases from pastebin into commands?

I was wondering if there was a way to pull words and phrases from a paste bin for a command?

In nightbot I have one, and I’d like to move it over to Wizebot.

It looks like this:

$(user) embarked on a foraging adventure :wood::herb::mushroom:. You whimsically wandered through the lush magical woods :evergreen_tree::deciduous_tree::woman_fairy:t2::sparkles:. $(eval a=$(urlfetch json PASTE BIN LINK);a[Math.floor(Math.random()*a.length)]), $(eval a=$(urlfetch json PASTE BIN LINK);a[Math.floor(Math.random()*a.length)]). What you see is $(eval a=$(urlfetch json PASTE BIN LINK);a[Math.floor(Math.random()*a.length)])!

It comes out something like this:

So its comes out something like:

kjshroomish embarked on a foraging adventure :wood::herb::mushroom:. You whimsically wandered through the lush magical woods :evergreen_tree::deciduous_tree::woman_fairy:t2::sparkles:. Pausing to admire the intricate patterns of ferns unfurling, you feel a sense of wonder at nature’s artistry. :herb::leaves::seedling:, then, something peculiar draws your attention… What you see is small, star-like white flowers and smooth, oval leaves. You have discovered a Chickweed (Stellaria media):herb::sparkles:!

Hello,
You can do this via the “JS” command script system (with the JS command type):

// Function to fetch JSON data from a URL
function fetchJsonData(url) {
    return JS.wizebot.call_tag("urlcall", [url]);
}

// Function to get a random element from an array
function getRandomElement(arr) {
    return arr[Math.floor(Math.random() * arr.length)];
}

// The Pastebin link containing the JSON array
let pastebinLink = "PASTE_BIN_LINK"; // Replace with your actual Pastebin link

// Fetch the JSON data from the Pastebin link
let jsonData = fetchJsonData(pastebinLink);

// Check if the data was successfully fetched
if (jsonData) {
    // Parse the fetched JSON data
    let data = JSON.parse(jsonData);

    // Get three random phrases
    let phrase1 = getRandomElement(data);
    let phrase2 = getRandomElement(data);
    let phrase3 = getRandomElement(data);

    // Construct the final message with emojis
    let user = JS.datas('nick'); // The user's nickname who triggered the command
    let message = `${user} embarked on a foraging adventure 🪵🌿🍄. You whimsically wandered through the lush magical woods 🌲🌳🧚‍♀️✨. ${phrase1}, ${phrase2}. What you see is ${phrase3}!`;

    // Send the message to the chat
    JS.wizebot.send_chat_message(message);
} else {
    // Handle the case where the data couldn't be fetched
    JS.wizebot.send_chat_message("Error: Unable to fetch data from the provided link.");
}

This script was generated using our official ChatGPT assistant: ChatGPT - Wize.Bot - JS Helper :slight_smile:

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