Skip to content

Commit

Permalink
chore: update deps
Browse files Browse the repository at this point in the history
  • Loading branch information
dan-online committed Sep 27, 2022
1 parent 702dbfa commit fc07da6
Show file tree
Hide file tree
Showing 6 changed files with 95 additions and 6 deletions.
2 changes: 1 addition & 1 deletion deps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
6 changes: 6 additions & 0 deletions src/commands/class.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,12 @@ createCommand({
"Source",
"Link",
cls.source?.url || "https://josh.evie.dev",
).addButton(
"Website",
"Link",
`https://joshdocs.netlify.app/docs/${
cls.project.name.split("/")[1]
}/classes#${cls.name}`,
),
},
},
Expand Down
80 changes: 80 additions & 0 deletions src/commands/eval.ts
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,
},
},
);
}
},
});
6 changes: 6 additions & 0 deletions src/commands/method.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,12 @@ createCommand({
"Source",
"Link",
method.source?.url || "https://josh.evie.dev",
).addButton(
"Website",
"Link",
`https://joshdocs.netlify.app/docs/${
method.project.name.split("/")[1]
}/methods#${method.parent.name}-${method.name}`,
),
},
},
Expand Down
6 changes: 1 addition & 5 deletions src/utils/docs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,7 @@ export const resolveReferenceType = (type: ReferenceTypeParser) => {
};

export const resolveType = (type: TypeParser) => {
if (type instanceof ReferenceTypeParser) {
return resolveReferenceType(type);
}

return type.toString();
return `[${type.toString()}](https://joshdocs.netlify.app/)`;
};

let filesCache: { date?: Date; files: File[] };
Expand Down
1 change: 1 addition & 0 deletions src/utils/notFound.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ export const notFound = async (
{
type: InteractionResponseTypes.ChannelMessageWithSource,
data: {
flags: 1 << 6,
embeds: new Embeds(bot)
.setTitle(name + " not found")
.setColor(BOT_COLOR)
Expand Down

0 comments on commit fc07da6

Please sign in to comment.