veeeee 😭
This commit is contained in:
commit
fe0df783a3
3 changed files with 262 additions and 0 deletions
107
index.js
Normal file
107
index.js
Normal file
|
@ -0,0 +1,107 @@
|
|||
const {
|
||||
Client,
|
||||
ApplicationCommandOptionTypes,
|
||||
ApplicationCommandTypes,
|
||||
InteractionTypes,
|
||||
MessageFlags
|
||||
} = require("oceanic.js");
|
||||
|
||||
const client = new Client({
|
||||
auth: `Bot ${process.env.BOT_TOKEN}`
|
||||
});
|
||||
|
||||
async function evaluate(shitcode, intera) {
|
||||
const console = {
|
||||
_lines: [],
|
||||
_log(...things) {
|
||||
this._lines.push(
|
||||
...things
|
||||
.map((x) => inspect(x, { getters: true }))
|
||||
.join(" ")
|
||||
.split("\n")
|
||||
);
|
||||
}
|
||||
};
|
||||
console.log =
|
||||
console.error =
|
||||
console.warn =
|
||||
console.info =
|
||||
console._log.bind(console);
|
||||
|
||||
const int = intera;
|
||||
const fs = require("fs");
|
||||
const http = require("http");
|
||||
const https = require("https");
|
||||
const crypto = require("crypto");
|
||||
const net = require("net");
|
||||
const path = require("path");
|
||||
const util = require("util");
|
||||
const assert = require("assert");
|
||||
const os = require("os");
|
||||
const oceanic = require("oceanic.js");
|
||||
|
||||
let script = shitcode.replace(/(^`{3}(js|javascript)?|`{3}$)/g, "");
|
||||
if (script.includes("await")) script = `(async () => { ${script} })()`;
|
||||
|
||||
try {
|
||||
return await eval(script);
|
||||
} catch (e) {
|
||||
return e;
|
||||
}
|
||||
}
|
||||
|
||||
client.on("ready", () => {
|
||||
console.log(`Logged in as ${client.user.username}`);
|
||||
client.application.bulkEditGlobalCommands([
|
||||
{
|
||||
name: "say",
|
||||
description: "Says whatever you provide",
|
||||
options: [
|
||||
{
|
||||
name: "content",
|
||||
description: "...",
|
||||
type: ApplicationCommandOptionTypes.STRING,
|
||||
required: true
|
||||
},
|
||||
{
|
||||
name: "raw",
|
||||
description: "...",
|
||||
type: ApplicationCommandOptionTypes.BOOLEAN,
|
||||
required: false
|
||||
},
|
||||
{
|
||||
name: "eval",
|
||||
description: "...",
|
||||
type: ApplicationCommandOptionTypes.BOOLEAN,
|
||||
required: false
|
||||
}
|
||||
]
|
||||
}
|
||||
]);
|
||||
});
|
||||
|
||||
client.on("interactionCreate", async (interaction) => {
|
||||
if (InteractionTypes.APPLICATION_COMMAND === interaction.type) {
|
||||
await interaction.defer();
|
||||
await interaction.deleteOriginal();
|
||||
if (interaction.data.type === ApplicationCommandTypes.CHAT_INPUT) {
|
||||
const content = interaction.data.options.getString("content", true);
|
||||
const raw = interaction.data.options.getBoolean("raw");
|
||||
const shouldEval = interaction.data.options.getBoolean("eval");
|
||||
|
||||
interaction.createFollowup(
|
||||
shouldEval
|
||||
? {
|
||||
content: await evaluate(content, interaction)
|
||||
}
|
||||
: raw
|
||||
? JSON.parse(content)
|
||||
: {
|
||||
content
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
client.connect();
|
Loading…
Add table
Add a link
Reference in a new issue