-
Notifications
You must be signed in to change notification settings - Fork 0
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
0 parents
commit 4b9f565
Showing
5 changed files
with
2,005 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
.env | ||
node_modules/ | ||
ngrok.exe | ||
ngrok.old.exe |
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 |
---|---|---|
@@ -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")); |
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 |
---|---|---|
@@ -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")); |
Oops, something went wrong.
4b9f565
There was a problem hiding this comment.
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