imvumafia chat logger - Discord Webhook

Toolyx
by Toolyx · 3 posts
1 year ago in Javascript
Posted 1 year ago · Author
Code
const webhookURL = "Your Discord Webhook";

// Initialize variables
let lastMessage = "";
let sentMessages = new Set();

// Function to send message to webhook
async function sendToWebhook(data) {
    // Send message to webhook
    const response = await fetch(webhookURL, {
        method: "POST",
        headers: { "Content-Type": "application/json" },
        body: JSON.stringify(data),
    });

    if (!response.ok) {
        throw new Error(`Failed to send data to webhook: ${response.status}`);
    }
}

// Function to listen for new messages
function listen() {
    let els = document.querySelectorAll(".mChatMessageRow");
    if (els.length > 0) {
        els.forEach((el) => {
            let message = el.querySelector(".mChatMessage").textContent.trim();
            let username = el.querySelector(".mChatMessage a").textContent.trim();
            let avatar = el.querySelector(".mChatAvatar img").getAttribute("src");

            if (lastMessage !== message) {
                lastMessage = message;
                if (!sentMessages.has(message)) {
                    sentMessages.add(message);
                    // remove spaces from message
                    message = message.replace(/\s/g, "");
               
                   
                    sendToWebhook({
                        content: message,

                    });
                    console.log(message, username, avatar);
                }
            }
        });
    }
    setTimeout(listen, 1000);
}

// Start listening for new messages
listen();



Just for fun, not meant to be great, lol.

This code is for a Discord webhook that logs the IMVU Mafias mchat shoutbox.

Navigate to the server you want to create the webhook on.

Click on the server settings button, which is represented by a gear icon.

In the server settings, navigate to the "Webhooks" tab.

Click on the "Create Webhook" button.

Click the "copy webhook URL" button to get your webhook's auth token.

Copy your token and place it where it says (YOUR WEBHOOK URL!) into the script.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Sign in

Already have an account? Sign in here

SIGN IN NOW

Create an account

Sign up for a new account in our community. It's easy!

REGISTER A NEW ACCOUNT
Select a forum Protection     Help & Support     Introductions     Mafia News     IMVU News General Discussion     IMVU Lounge        IMVU Series / Roleplaying        Social Games     Mafia Market     Mafia Tools        Premium IMVU Tools        Off Topic Tools     Off Topic     Contests Creator Corner     Graphics Design        Photoshop        GIMP     Basic Creator Help     Catalog And Product Showcase     3D Meshing        3Ds Max        Sketchup        Blender Gangsters with Connections     White Hat Activities        Google Hacking        Trackers Programming Corner     Coding        Python        .Net (C#, VB, etc)        Flash        JAVA        Autoit        Batch        HTML & CSS        Javascript        PHP        Other        IMVU Homepage Codes           General           About me Panel           Messages Panel           Special Someone Panel           Visitors Panel           New Products Panel           Rankings Panel           Wishlist Panel           My Badges Panel           Outfits Panel           Url Panel           Groups Panel           Slideshow Panel           My Room Panel           Sandbox panel           Layouts     Help & Requests Free Credits     Approved Methods     Submit Methods Free Money     Approved Methods     Submit Methods Adult Corner     Get Mafia AP Here     AP Lounge        AP Social Games        Casual Dating Tips     IMVU Slave Market & Escorts