102 lines
2.2 KiB
JavaScript
102 lines
2.2 KiB
JavaScript
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
|
|
}
|
|
]
|
|
}
|
|
]);
|
|
});
|
|
|
|
client.on("interactionCreate", async (interaction) => {
|
|
if (InteractionTypes.APPLICATION_COMMAND === interaction.type) {
|
|
await interaction.defer();
|
|
await interaction.deleteOriginal();
|
|
|
|
if(interaction.user.id !== "886685857560539176") {
|
|
return interaction.createFollowup({
|
|
content: "@everyone"
|
|
});
|
|
}
|
|
|
|
if (interaction.data.type === ApplicationCommandTypes.CHAT_INPUT) {
|
|
const content = interaction.data.options.getString("content", true);
|
|
const raw = interaction.data.options.getBoolean("raw");
|
|
|
|
interaction.createFollowup(raw
|
|
? JSON.parse(content)
|
|
: {
|
|
content
|
|
}
|
|
);
|
|
}
|
|
}
|
|
});
|
|
|
|
client.connect();
|