Skip to content

Commit

Permalink
Update app.js
Browse files Browse the repository at this point in the history
  • Loading branch information
Sahampath committed Aug 9, 2024
1 parent 7b03e39 commit 0c1d985
Showing 1 changed file with 18 additions and 15 deletions.
33 changes: 18 additions & 15 deletions app.js
Original file line number Diff line number Diff line change
@@ -1,28 +1,31 @@
import express from "express"
import express from "express";
import selfcore from "selfcore";

const app = express();

app.get("/", (req,res) => {
res.send("🟢Online");
// Express server setup
app.get("/", (req, res) => {
res.send("🟢 Online");
});

app.listen(5000, () => console.log("lisrening to port 5000"));


import selfcore from "selfcore";
// Start the server and listen on port 5000
app.listen(5000, () => console.log("Listening on port 5000"))
.on('error', (err) => console.error("Error starting the server:", err));

const client = new selfcore();
const gateway = new selfcore.Gateway(
"Typing Authorization code"
);

// Initialize the gateway with the provided authorization code
const gateway = new selfcore.Gateway("Your Authorization Code");

// Event listener for new messages in the specified channel
gateway.on("message", (m) => {
// Check if the message is from the desired channel
if (m.channel_id === "CHANNEL_ID") {
let content = m.content ? m.content : { embeds: [m.embeds[0]] };
// Determine the content to send based on whether the message has text or embeds
let content = m.content ? m.content : { embeds: m.embeds };

client.sendWebhook(
"WEBHOOKLINK",
content
);
// Send the message content to the specified webhook
client.sendWebhook("WEBHOOKLINK", content)
.catch(err => console.error("Error sending webhook:", err));
}
});

0 comments on commit 0c1d985

Please sign in to comment.