Updated API n stuff (committing so I can reset my pc)
This commit is contained in:
+2
-1
@@ -1,2 +1,3 @@
|
||||
old
|
||||
api/node_modules
|
||||
api/node_modules
|
||||
api/.env
|
||||
@@ -0,0 +1,62 @@
|
||||
const express = require('express');
|
||||
const cors = require('cors');
|
||||
const morgan = require('morgan');
|
||||
const axios = require('axios');
|
||||
const chalk = require('chalk');
|
||||
const discord = require('discord.js');
|
||||
|
||||
const app = express();
|
||||
|
||||
// .use statements
|
||||
app.use(express.json());
|
||||
app.use(cors());
|
||||
app.use(morgan('dev'));
|
||||
|
||||
// GET Endpoints
|
||||
app.get('/', (req, res) => {
|
||||
return res.send({ "status": 200 })
|
||||
})
|
||||
|
||||
// POST Endpoints
|
||||
app.post('/splitstat/webhook', async (req, res) => {
|
||||
if(req.headers['authorization'] === `${process.env.auth}`) {
|
||||
try {
|
||||
if(req.body.user) {
|
||||
const webhookClient = new discord.WebhookClient({ id: process.env.webhookId, token: process.env.webhookToken });
|
||||
|
||||
const user = await axios.get(`https://discord.com/api/users/${req.body.user}`, {
|
||||
method: 'GET',
|
||||
headers: { 'authorization': `Bot ${process.env.token}` }
|
||||
})
|
||||
|
||||
await webhookClient.send({
|
||||
content: `Thanks **${user.data.username}#${user.data.discriminator}** for [voting for SplitStat](https://top.gg/bot/868689248218411050/vote) on **Top.gg**!`,
|
||||
username: `SplitStat - Voting!`,
|
||||
avatarURL: `https://cdn.discordapp.com/app-icons/868689248218411050/cfb8eb37a8dcacefc9228d0949667ff1.png`
|
||||
})
|
||||
} else {
|
||||
res.status(500).send({ "stauts": 500, "message": "Incorrect payload sent" })
|
||||
}
|
||||
|
||||
} catch(err) {
|
||||
console.log(chalk.redBright.bold(`API error!`), err)
|
||||
return res.status(500).send({ "status": 500, "errors": err.message })
|
||||
}
|
||||
|
||||
return res.status(200).send({ "status": 200, "message": "Event successfully emitted to Discord" })
|
||||
} else {
|
||||
res.status(401).send({ "status": 401, "message": "Only top.gg is authorized to post here. Go away." })
|
||||
}
|
||||
})
|
||||
|
||||
app.use(function (req, res, next) {
|
||||
res.status(404).send({ "status": 404, "message": `Sorry, that endpoint (${req.path}) does not exist.` })
|
||||
})
|
||||
|
||||
app.use(function (error, req, res, next) {
|
||||
res.status(500).send({ "status": 500, "message": "Something broke! Looking into it :)" })
|
||||
})
|
||||
|
||||
app.listen(process.env.PORT, () => {
|
||||
console.log(`Started`)
|
||||
})
|
||||
Generated
+1608
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"name": "api",
|
||||
"version": "1.0.0",
|
||||
"description": "",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"keywords": [],
|
||||
"author": "Awex",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"axios": "^0.24.0",
|
||||
"chalk": "^4.1.2",
|
||||
"cors": "^2.8.5",
|
||||
"discord.js": "^13.3.0",
|
||||
"dotenv": "^10.0.0",
|
||||
"express": "^4.17.1",
|
||||
"morgan": "^1.10.0"
|
||||
}
|
||||
}
|
||||
@@ -83,7 +83,6 @@
|
||||
</a>
|
||||
<div class="dropdown-menu sm-menu">
|
||||
<a class="dropdown-item" href="https://mcw.awexxx.xyz">Medal Clip Webhook</a>
|
||||
<a class="dropdown-item" href="/tools/discord">Discord Webhook Sender</a>
|
||||
<a class="dropdown-item" href="https://awexxx.xyz/splitstat">Splitstat Discord Bot</a>
|
||||
<!-- <a class="dropdown-item" href="#">yes</a> -->
|
||||
</div>
|
||||
|
||||
@@ -77,7 +77,6 @@
|
||||
</a>
|
||||
<div class="dropdown-menu sm-menu">
|
||||
<a class="dropdown-item" href="https://mcw.awexxx.xyz">Medal Clip Webhook</a>
|
||||
<a class="dropdown-item" href="/tools/discord">Discord Webhook Sender</a>
|
||||
<a class="dropdown-item" href="#">Splitstat Discord Bot</a>
|
||||
</div>
|
||||
</li>
|
||||
|
||||
@@ -77,7 +77,6 @@
|
||||
</a>
|
||||
<div class="dropdown-menu sm-menu">
|
||||
<a class="dropdown-item" href="https://mcw.awexxx.xyz">Medal Clip Webhook</a>
|
||||
<a class="dropdown-item" href="/tools/discord">Discord Webhook Sender</a>
|
||||
<a class="dropdown-item" href="#">Splitstat Discord Bot</a>
|
||||
</div>
|
||||
</li>
|
||||
@@ -105,7 +104,7 @@
|
||||
|
||||
<h3>SplitStat - Privacy and how I handle it</h3>
|
||||
<p>SplitStat operates the SplitStat Discord Bot & all content at https://awexxx.xyz/splitstatbot.<br>SplitStat will never ask for any personal information unless we so need it to provide the Service.<br>
|
||||
SplitStat will only log/retain data that may be collected from you adding the bot to the server, any commands that were ran and by who, and specific info regarding your stats.. This includes but is not limited to;<br>
|
||||
SplitStat will only log/retain data that may be collected from you adding the bot to the server, along specific info regarding your stats. This includes but is not limited to;<br>
|
||||
<ul>
|
||||
<li>Guild IDs</li>
|
||||
<li>Timestamps of join/leave</li>
|
||||
|
||||
@@ -77,7 +77,6 @@
|
||||
</a>
|
||||
<div class="dropdown-menu sm-menu">
|
||||
<a class="dropdown-item" href="https://mcw.awexxx.xyz">Medal Clip Webhook</a>
|
||||
<a class="dropdown-item" href="/tools/discord">Discord Webhook Sender</a>
|
||||
<a class="dropdown-item" href="#">Splitstat Discord Bot</a>
|
||||
</div>
|
||||
</li>
|
||||
|
||||
@@ -1,134 +0,0 @@
|
||||
<style>
|
||||
html {
|
||||
scroll-behavior: smooth;
|
||||
}
|
||||
|
||||
hr {
|
||||
border-color:black;
|
||||
}
|
||||
</style>
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<title>Awex >> Discord Embed Creator</title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<link rel="stylesheet" href="../assets/css/style.css">
|
||||
<link rel="stylesheet" href="../assets/css/footer.css">
|
||||
<link rel="stylesheet" href="../assets/css/nav.css">
|
||||
<link rel="stylesheet" href="../assets/css/form.css">
|
||||
<link rel="preconnect" href="https://fonts.googleapis.com">
|
||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
||||
<link href="https://fonts.googleapis.com/css2?family=Quicksand:wght@300&display=swap" rel="stylesheet">
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/ionicons/2.0.1/css/ionicons.min.css">
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.1.3/css/bootstrap.min.css">
|
||||
|
||||
<!-- Scripts -->
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.1.3/js/bootstrap.bundle.min.js"></script>
|
||||
<script type="module" src="https://unpkg.com/ionicons@5.5.2/dist/ionicons/ionicons.esm.js"></script>
|
||||
<script nomodule src="https://unpkg.com/ionicons@5.5.2/dist/ionicons/ionicons.js"></script>
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js"></script>
|
||||
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js"></script>
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function () {
|
||||
$('.navbar-light .dmenu').hover(function () {
|
||||
$(this).find('.sm-menu').first().stop(true, true).slideDown(150);
|
||||
}, function () {
|
||||
$(this).find('.sm-menu').first().stop(true, true).slideUp(105)
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
<!-- Meta Tags -->
|
||||
<meta content="Awexxx" property="og:title">
|
||||
<meta content="Hello! My name is Awex and I'm a developer doing dev stuff! This is my cool website!" property="og:description">
|
||||
<meta content="https://awexxx.xyz/discord" property="og:url">
|
||||
<meta content="#9c2d1c" data-react-helmet="true" name="theme-color">
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<nav class="navbar navbar-expand-sm navbar-light bg-light">
|
||||
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarTogglerDemo03" aria-controls="navbarTogglerDemo03" aria-expanded="false" aria-label="Toggle navigation">
|
||||
<span class="navbar-toggler-icon"></span>
|
||||
</button>
|
||||
|
||||
<div class="collapse navbar-collapse" id="navbarTogglerDemo03">
|
||||
<ul class="navbar-nav mr-auto mt-2 mt-lg-0">
|
||||
<li class="nav-item">
|
||||
<a class="nav-link"><Awex /><span class="sr-only"></span></a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="https://awexxx.xyz">Home <span class="sr-only">(current)</span></a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="mailto:hi@awexxx.xyz">Contact</a>
|
||||
</li>
|
||||
<li class="nav-item dropdown dmenu">
|
||||
<a class="nav-link dropdown-toggle" href="#" id="navbardrop" data-toggle="dropdown">
|
||||
Tools
|
||||
</a>
|
||||
<div class="dropdown-menu sm-menu">
|
||||
<a class="dropdown-item" href="https://mcw.awexxx.xyz">Medal Clip Webhook</a>
|
||||
<a class="dropdown-item" href="#">Discord Webhook Sender</a>
|
||||
<a class="dropdown-item" href="https://awexxx.xyz/splitstat">Splitstat Discord Bot</a>
|
||||
</div>
|
||||
</li>
|
||||
<!-- <li class="nav-item dropdown dmenu">
|
||||
<a class="nav-link dropdown-toggle" href="#" id="navbardrop" data-toggle="dropdown">
|
||||
Dropdown link
|
||||
</a>
|
||||
<div class="dropdown-menu sm-menu">
|
||||
<a class="dropdown-item" href="#">Link 1</a>
|
||||
<a class="dropdown-item" href="#">Link 2</a>
|
||||
<a class="dropdown-item" href="#">Link 3</a>
|
||||
<a class="dropdown-item" href="#">Link 4</a>
|
||||
<a class="dropdown-item" href="#">Link 5</a>
|
||||
<a class="dropdown-item" href="#">Link 6</a>
|
||||
</div>
|
||||
</li> -->
|
||||
</ul>
|
||||
<div class="social-part">
|
||||
<i class="fa fa-facebook" aria-hidden="true"></i>
|
||||
<i class="fa fa-twitter" aria-hidden="true"></i>
|
||||
<i class="fa fa-instagram" aria-hidden="true"></i>
|
||||
</div>
|
||||
</div>
|
||||
</nav><br>
|
||||
|
||||
|
||||
<div id="form">
|
||||
<h3>Discord Webhook -- Embed Creator</h3>
|
||||
<hr>
|
||||
<form action="https://api.awexxx.xyz/tools/discord" method="POST">
|
||||
<input style="font-size: 15px;" type="text" id="url" name="url" placeholder="Webhook URL.." required><br>
|
||||
<input style="font-size: 15px;" type="text" id="disuser" name="disuser" placeholder="Webhook Username.." required><br>
|
||||
<input style="font-size: 15px;" type="text" id="description" name="description" placeholder="Description.."><br>
|
||||
<input style="font-size: 15px;" type="text" id="image" name="image" placeholder="Image URL.."><br>
|
||||
<input style="font-size: 15px;" type="text" id="avimage" name="avimage" placeholder="Avatar Image URL.."><br>
|
||||
<input style="font-size: 15px;" type="text" id="title" name="title" placeholder="Title.." required></input><br>
|
||||
<input style="font-size: 15px;" type="text" id="color" name="color" placeholder="Color (NOT HEX, NUMERICAL FORM).." required></input><br>
|
||||
<button class="button" id="submit" type="submit">Submit..</button><br><br>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<div class="footer-basic">
|
||||
<footer>
|
||||
<div class="social"><a href="https://instagram.com/_awexx"><i class="icon ion-social-instagram"></i></a><a href="https://twitter.com/lulawex"><i class="icon ion-social-twitter"></i></a><a href="https://github.com/awexxx/"><i class="icon ion-social-github"></i></a></div>
|
||||
<ul class="list-inline">
|
||||
<li class="list-inline-item"><a href="https://mcw.awexxx.xyz">Medal Clip Webhook</a></li>
|
||||
</ul>
|
||||
<p class="copyright">hi@awexxx.xyz<br>
|
||||
</footer>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
||||
<style>
|
||||
body {
|
||||
background-color:#dedede;
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user