+3
-3
src/commands/dong/create.ts
+3
-3
src/commands/dong/create.ts
···
1
1
import {
2
-
Attachment,
3
2
AttachmentBuilder,
4
3
ChatInputCommandInteraction,
5
4
SlashCommandBuilder,
6
5
} from "discord.js";
7
-
import type { customClient } from "../..";
6
+
import type { customClient } from "../../index.ts";
8
7
import { createDong } from "../../lib/dong-io.ts";
9
8
import { download } from "../../lib/download.ts";
9
+
import { Buffer } from "node:buffer";
10
10
11
11
export const data = new SlashCommandBuilder()
12
12
.setName("create")
···
47
47
48
48
await interaction.deferReply();
49
49
50
-
let downloaded = {
50
+
const downloaded = {
51
51
image: await download(image),
52
52
audio: await download(audio),
53
53
};
+1
src/commands/dong/open.ts
+1
src/commands/dong/open.ts
+2
-5
src/commands/util/ping.ts
+2
-5
src/commands/util/ping.ts
···
1
-
import {
2
-
ChatInputCommandInteraction,
3
-
SlashCommandBuilder,
4
-
} from "discord.js";
5
-
import type { customClient } from "../..";
1
+
import { ChatInputCommandInteraction, SlashCommandBuilder } from "discord.js";
2
+
import type { customClient } from "../../index.ts";
6
3
7
4
export const data = new SlashCommandBuilder()
8
5
.setName("ping")
+7
-5
src/index.ts
+7
-5
src/index.ts
···
8
8
type Interaction,
9
9
} from "discord.js";
10
10
import { glob } from "node:fs/promises";
11
-
import path from "node:path";
12
11
13
-
console.log(process.env);
14
-
15
-
const token = process.env.TOKEN;
12
+
const token = Deno.env.get("TOKEN");
16
13
if (!token) throw new Error("Token required. Please fill in TOKEN in .env");
17
14
console.log("Token Valid!");
18
15
···
42
39
for await (const file of glob("src/commands/**/*.ts", {
43
40
exclude: ["node_modules"],
44
41
})) {
45
-
const command = await import("file:///" + path.join(__dirname, "..", file));
42
+
console.log(file);
43
+
const command = await import(`../${file}`);
46
44
// check command contains all required properties
47
45
if (
48
46
"data" in command &&
···
76
74
console.error(`No command ${interaction.commandName}`);
77
75
return;
78
76
}
77
+
78
+
console.log(
79
+
`Got command /${interaction.commandName} from @${interaction.user.username}`
80
+
);
79
81
80
82
try {
81
83
await command.execute(interaction);
+1
-12
src/lib/dong-io.ts
+1
-12
src/lib/dong-io.ts
···
4
4
}
5
5
}
6
6
7
-
const blobBytes = async (blob: Blob) => {
7
+
const blobBytes = (blob: Blob) => {
8
8
if ("bytes" in blob) return blob.bytes();
9
9
return new Response(blob).arrayBuffer().then((buffer) => {
10
10
const uint = new Uint8Array(buffer);
···
107
107
},
108
108
};
109
109
}
110
-
111
-
export const download = (file: File) => {
112
-
const url = URL.createObjectURL(file);
113
-
const a = document.createElement("a");
114
-
a.href = url;
115
-
a.download = file.name;
116
-
document.body.appendChild(a);
117
-
a.click();
118
-
document.body.removeChild(a);
119
-
URL.revokeObjectURL(url);
120
-
};
+5
-1
src/sync.js
+5
-1
src/sync.js
···
1
1
import { REST, Routes } from "discord.js";
2
-
const { CLIENT: clientId, TOKEN: token } = process.env;
3
2
import fs from "node:fs";
4
3
import path from "node:path";
4
+
5
+
const clientId = Deno.env.get("CLIENT");
6
+
const token = Deno.env.get("TOKEN");
7
+
if (!clientId) throw "CLIENT not defined";
8
+
if (!token) throw "TOKEN not defined";
5
9
6
10
const commands = [];
7
11
// Grab all the command folders from the commands directory you created earlier