Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
larsdekooter committed Oct 1, 2022
0 parents commit 4b9f565
Show file tree
Hide file tree
Showing 5 changed files with 2,005 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.env
node_modules/
ngrok.exe
ngrok.old.exe
14 changes: 14 additions & 0 deletions dc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { REST } from "@discordjs/rest";
import { Routes } from "discord-api-types/v10";
import { SlashCommandBuilder } from "@discordjs/builders";
import "dotenv/config";
const rest = new REST().setToken(process.env.token);

rest
.put(
Routes.applicationGuildCommands("986610393843642388", "950680035411501056"),
{
body: [new SlashCommandBuilder().setName("grav").setDescription("grav")],
}
)
.then(console.log("hello"));
46 changes: 46 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import { verifyKeyMiddleware } from "discord-interactions";
import express from "express";
import { InteractionResponseType } from "discord-api-types/v10";
class Interaction {
data;
constructor(interaction) {
this.data = interaction.data;
}
get commandName() {
return this.data.name;
}
}
const app = express();
app.get("/", (req, res) => res.send("Here I am"));
app.get(
"/inter",
verifyKeyMiddleware(
"d8c09e3ffb1c254322b098b64801f519d5401b07feccc272954739fb81c6f49a"
),
async (req, res) => {
async function reply(options) {
options =
typeof options === "string"
? (options = { content: options })
: options;
return res.send({
data: options,
type: InteractionResponseType.ChannelMessageWithSource,
});
}
const interaction = new Interaction(req.body);
if (interaction.commandName === "grav") {
return reply({ content: calculateGravity().toString() });
}
}
);
function calculateGravity(
r = 6.4e6, //6,4 * 10⁶
G = 6.67e-11, //6,67 * 10⁻¹¹
M = 6.0e24 //6,0 * 10²⁴
) {
const { pow } = Math; // Get the pow function to use exponents (first parameter is the x (1), second is the y (²))
const Fz = (G * M) / pow(r, 2); // Fz === Fg = mg === G * (mM / r²) = g ==== G * (M / r²);
return Fz;
}
app.listen(3000, () => console.log("seeya"));
Loading

1 comment on commit 4b9f565

@vercel
Copy link

@vercel vercel bot commented on 4b9f565 Oct 1, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

utilbot – ./

utilbot-git-master-larsdekooter.vercel.app
utilbot.vercel.app
utilbot-larsdekooter.vercel.app

Please sign in to comment.