-
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
1 parent
702dbfa
commit fc07da6
Showing
6 changed files
with
95 additions
and
6 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 |
---|---|---|
|
@@ -7,4 +7,4 @@ export { | |
export * from "https://deno.land/x/[email protected]/mod.ts"; | ||
export * from "https://deno.land/x/[email protected]/plugins/mod.ts"; | ||
export { config as dotEnvConfig } from "https://deno.land/x/[email protected]/mod.ts"; | ||
export * from "https://esm.sh/typedoc-json-parser@3.0.0"; | ||
export * from "https://esm.sh/typedoc-json-parser@5.0.0"; |
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
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,80 @@ | ||
import { BOT_COLOR } from "../../config.ts"; | ||
import { | ||
ApplicationCommandOptionTypes, | ||
ApplicationCommandTypes, | ||
InteractionResponseTypes, | ||
} from "../../deps.ts"; | ||
import * as docsUtils from "../utils/docs.ts"; | ||
import { Embeds } from "../utils/embed.ts"; | ||
import { createCommand } from "./mod.ts"; | ||
|
||
const docs = docsUtils; | ||
|
||
createCommand({ | ||
name: "eval", | ||
description: "Evaluate code", | ||
type: ApplicationCommandTypes.ChatInput, | ||
scope: "Global", | ||
options: [ | ||
{ | ||
name: "code", | ||
description: "Code", | ||
type: ApplicationCommandOptionTypes.String, | ||
required: true, | ||
}, | ||
], | ||
execute: async (bot, interaction) => { | ||
if (interaction.user.id !== 709674034798788617n) { | ||
return bot.helpers.sendInteractionResponse( | ||
interaction.id, | ||
interaction.token, | ||
{ | ||
type: InteractionResponseTypes.ChannelMessageWithSource, | ||
data: { | ||
flags: 1 << 6, | ||
content: "Sorry, you are not allowed to use this command", | ||
}, | ||
}, | ||
); | ||
} | ||
const inputCode = interaction.data?.options?.find( | ||
(x) => x.name === "code", | ||
)?.value as string; | ||
try { | ||
docs; // to be used | ||
let result = eval(inputCode); | ||
if (result instanceof Promise) { | ||
result = await result; | ||
} | ||
const embed = new Embeds(bot) | ||
.setTitle("Eval") | ||
.setColor(BOT_COLOR) | ||
.addField("Output", `\`\`\`ts\n${Deno.inspect(result)}\`\`\``); | ||
return bot.helpers.sendInteractionResponse( | ||
interaction.id, | ||
interaction.token, | ||
{ | ||
type: InteractionResponseTypes.ChannelMessageWithSource, | ||
data: { | ||
embeds: embed, | ||
}, | ||
}, | ||
); | ||
} catch (error) { | ||
const embed = new Embeds(bot) | ||
.setTitle("Eval") | ||
.setColor(BOT_COLOR) | ||
.addField("Output", `\`\`\`ts\n${error}\`\`\``); | ||
return bot.helpers.sendInteractionResponse( | ||
interaction.id, | ||
interaction.token, | ||
{ | ||
type: InteractionResponseTypes.ChannelMessageWithSource, | ||
data: { | ||
embeds: embed, | ||
}, | ||
}, | ||
); | ||
} | ||
}, | ||
}); |
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
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
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