diff --git a/clients/twitch.js b/clients/twitch.js index b7bbd16..f345739 100644 --- a/clients/twitch.js +++ b/clients/twitch.js @@ -1,10 +1,10 @@ -import { +const { AlternateMessageModifier, ChatClient, SlowModeRateLimiter, -} from "dank-twitch-irc"; +} = require("dank-twitch-irc"); -export let client = new ChatClient({ +let client = new ChatClient({ username: process.env.TWITCH_USERNAME, password: process.env.TWITCH_PASSWORD, @@ -14,3 +14,5 @@ export let client = new ChatClient({ client.use(new SlowModeRateLimiter(client)); client.use(new AlternateMessageModifier(client)); + +module.exports = { client }; diff --git a/commands/commands.js b/commands/commands.js index caa45e6..e440080 100644 --- a/commands/commands.js +++ b/commands/commands.js @@ -1,4 +1,4 @@ -import fs from "fs"; +const fs = require("fs"); const command = { name: "commands", @@ -17,4 +17,4 @@ const command = { }, }; -export default { command }; +module.exports = { command }; diff --git a/commands/fill.js b/commands/fill.js index 64dede9..0eb6ab0 100644 --- a/commands/fill.js +++ b/commands/fill.js @@ -20,4 +20,4 @@ const command = { }, }; -export default { command }; +module.exports = { command }; diff --git a/commands/fm.js b/commands/fm.js index eca23f2..e8cddc2 100644 --- a/commands/fm.js +++ b/commands/fm.js @@ -1,5 +1,3 @@ -import fetch from "node-fetch"; - const command = { name: "fm", desc: "get last played track from last.fm with your username", @@ -37,4 +35,4 @@ const command = { }, }; -export default { command }; +module.exports = { command }; diff --git a/commands/hn.js b/commands/hn.js index b653fd2..57b2982 100644 --- a/commands/hn.js +++ b/commands/hn.js @@ -18,4 +18,4 @@ const command = { }, }; -export default { command }; +module.exports = { command }; diff --git a/commands/join.js b/commands/join.js index a151ee5..db06c99 100644 --- a/commands/join.js +++ b/commands/join.js @@ -20,4 +20,4 @@ const command = { }, }; -export default { command }; +module.exports = { command }; diff --git a/commands/love.js b/commands/love.js index 784f649..5dd30bb 100644 --- a/commands/love.js +++ b/commands/love.js @@ -20,4 +20,4 @@ const command = { }, }; -export default { command }; +module.exports = { command }; diff --git a/commands/massping.js b/commands/massping.js index eaeaa39..9a1d294 100644 --- a/commands/massping.js +++ b/commands/massping.js @@ -45,4 +45,4 @@ const command = { }, }; -export default { command }; +module.exports = { command }; diff --git a/commands/ping.js b/commands/ping.js index 3b885ca..2221216 100644 --- a/commands/ping.js +++ b/commands/ping.js @@ -11,4 +11,4 @@ const command = { }, }; -export default { command }; +module.exports = { command }; diff --git a/commands/pyramid.js b/commands/pyramid.js index 07a1fcc..7d4b42c 100644 --- a/commands/pyramid.js +++ b/commands/pyramid.js @@ -32,4 +32,4 @@ const command = { }, }; -export default { command }; +module.exports = { command }; diff --git a/commands/rd.js b/commands/rd.js index c0262de..d02536f 100644 --- a/commands/rd.js +++ b/commands/rd.js @@ -26,4 +26,4 @@ const command = { }, }; -export default { command }; +module.exports = { command }; diff --git a/commands/rl.js b/commands/rl.js index b0e5e74..a13976e 100644 --- a/commands/rl.js +++ b/commands/rl.js @@ -33,4 +33,4 @@ const command = { }, }; -export default { command }; +module.exports = { command }; diff --git a/commands/short.js b/commands/short.js index 9ea826d..1e5bed2 100644 --- a/commands/short.js +++ b/commands/short.js @@ -25,4 +25,4 @@ const command = { }, }; -export default { command }; +module.exports = { command }; diff --git a/commands/sketch.js b/commands/sketch.js index a5fa762..202abc7 100644 --- a/commands/sketch.js +++ b/commands/sketch.js @@ -29,4 +29,4 @@ const command = { }, }; -export default { command }; +module.exports = { command }; diff --git a/commands/user.js b/commands/user.js index b454905..efa355e 100644 --- a/commands/user.js +++ b/commands/user.js @@ -32,4 +32,4 @@ const command = { }, }; -export default { command }; +module.exports = { command }; diff --git a/commands/weather.js b/commands/weather.js index b8a4fd0..c7e4f2d 100644 --- a/commands/weather.js +++ b/commands/weather.js @@ -1,5 +1,3 @@ -import fetch from "node-fetch"; - const command = { name: "weather", desc: "get the weather from wttr.in", @@ -36,4 +34,4 @@ const command = { }, }; -export default { command }; +module.exports = { command }; diff --git a/commands/yts.js b/commands/yts.js index 3665197..be9d55c 100644 --- a/commands/yts.js +++ b/commands/yts.js @@ -31,4 +31,4 @@ const command = { }, }; -export default { command }; +module.exports = { command }; diff --git a/index.js b/index.js index 64970a5..98e3fc3 100644 --- a/index.js +++ b/index.js @@ -1,7 +1,8 @@ -import { client } from "./clients/twitch.js"; -import { getCommands } from "./utils/commands.js"; +const { client } = require("./clients/twitch.js"); +const fs = require("fs"); +const { getCommands } = require("./utils/commands.js"); -const commands = await getCommands(); +const commands = getCommands(); client.on("ready", async () => console.log("Successfully connected to chat")); client.on("close", async (error) => { if (error != null) { @@ -19,6 +20,8 @@ client.on("PRIVMSG", async (msg) => { splitted.splice(1, 1); } + console.log(commands); + if (splitted[0] === "%") { try { await commands[splitted[1]].run(client, msg, splitted); diff --git a/package.json b/package.json index 0cd85fb..888a20a 100644 --- a/package.json +++ b/package.json @@ -9,10 +9,8 @@ "keywords": [], "author": "", "license": "ISC", - "type": "module", "dependencies": { "dank-twitch-irc": "^4.3.0", - "node-fetch": "^3.3.0", "nodemon": "^2.0.20" } } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index c9908e0..c539aac 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -2,12 +2,10 @@ lockfileVersion: 5.4 specifiers: dank-twitch-irc: ^4.3.0 - node-fetch: ^3.3.0 nodemon: ^2.0.20 dependencies: dank-twitch-irc: 4.3.0 - node-fetch: 3.3.0 nodemon: 2.0.20 packages: @@ -115,11 +113,6 @@ packages: - utf-8-validate dev: false - /data-uri-to-buffer/4.0.1: - resolution: {integrity: sha512-0R9ikRb668HB7QDxT1vkpuUBtqc53YyAwMwGeUFKRojY/NWKvdZ+9UYtRfGmhqNbRkTSVpMbmyhXipFFv2cb/A==} - engines: {node: '>= 12'} - dev: false - /debug-logger/0.4.1: resolution: {integrity: sha512-bLX6pxuWO6KMXBRk6vpLgHqWXiuLbKp8kLL/wNEA4rgU8wsNLaw3UNz0NfOi1bcN0JwjFwSfxhldzU5Bc6P5RQ==} dependencies: @@ -182,14 +175,6 @@ packages: resolution: {integrity: sha512-8guHBZCwKnFhYdHr2ysuRWErTwhoN2X8XELRlrRwpmfeY2jjuUN4taQMsULKUVo1K4DvZl+0pgfyoysHxvmvEw==} dev: false - /fetch-blob/3.2.0: - resolution: {integrity: sha512-7yAQpD2UMJzLi1Dqv7qFYnPbaPx7ZfFK6PiIxQ4PfkGPyNyl2Ugx+a/umUonmKqjhM4DnfbMvdX6otXq83soQQ==} - engines: {node: ^12.20 || >= 14.13} - dependencies: - node-domexception: 1.0.0 - web-streams-polyfill: 3.2.1 - dev: false - /fill-range/7.0.1: resolution: {integrity: sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==} engines: {node: '>=8'} @@ -197,13 +182,6 @@ packages: to-regex-range: 5.0.1 dev: false - /formdata-polyfill/4.0.10: - resolution: {integrity: sha512-buewHzMvYL29jdeQTVILecSaZKnt/RJWjoZCF5OW60Z67/GmSLBkOFM7qh1PI3zFNtJbaZL5eQu1vLfazOwj4g==} - engines: {node: '>=12.20.0'} - dependencies: - fetch-blob: 3.2.0 - dev: false - /fsevents/2.3.2: resolution: {integrity: sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==} engines: {node: ^8.16.0 || ^10.6.0 || >=11.0.0} @@ -292,20 +270,6 @@ packages: resolution: {integrity: sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==} dev: false - /node-domexception/1.0.0: - resolution: {integrity: sha512-/jKZoMpw0F8GRwl4/eLROPA3cfcXtLApP0QzLmUT/HuPCZWyB7IY9ZrMeKw2O/nFIqPQB3PVM9aYm0F312AXDQ==} - engines: {node: '>=10.5.0'} - dev: false - - /node-fetch/3.3.0: - resolution: {integrity: sha512-BKwRP/O0UvoMKp7GNdwPlObhYGB5DQqwhEDQlNKuoqwVYSxkSZCSbHjnFFmUEtwSKRPU4kNK8PbDYYitwaE3QA==} - engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} - dependencies: - data-uri-to-buffer: 4.0.1 - fetch-blob: 3.2.0 - formdata-polyfill: 4.0.10 - dev: false - /nodemon/2.0.20: resolution: {integrity: sha512-Km2mWHKKY5GzRg6i1j5OxOHQtuvVsgskLfigG25yTtbyfRGn/GNvIbRyOf1PSCKJ2aT/58TiuUsuOU5UToVViw==} engines: {node: '>=8.10.0'} @@ -477,11 +441,6 @@ packages: resolution: {integrity: sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==} dev: false - /web-streams-polyfill/3.2.1: - resolution: {integrity: sha512-e0MO3wdXWKrLbL0DgGnUV7WHVuw9OUvL4hjgnPkIeEvESk74gAITi5G606JtZPp39cd8HA9VQzCIvA49LpPN5Q==} - engines: {node: '>= 8'} - dev: false - /wrappy/1.0.2: resolution: {integrity: sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==} dev: false diff --git a/utils/commands.js b/utils/commands.js index 9e287c6..7ef2bbf 100644 --- a/utils/commands.js +++ b/utils/commands.js @@ -1,16 +1,18 @@ -import fs from "fs"; +const fs = require("fs"); -export async function getCommands() { +function getCommands() { const commands = {}; const commandFiles = fs .readdirSync("./commands") .map((file) => file.replace(".js", "")); for (let file of commandFiles) { - await import(`../commands/${file}.js`).then( + import(`../commands/${file}.js`).then( (cmd) => (commands[file] = cmd.default.command) ); } return commands; } + +module.exports = { getCommands };