-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
18 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)); | ||
} | ||
}); |