es6 -> commonjs
This commit is contained in:
parent
12809f7656
commit
41e7e4102c
|
@ -1,10 +1,10 @@
|
||||||
import {
|
const {
|
||||||
AlternateMessageModifier,
|
AlternateMessageModifier,
|
||||||
ChatClient,
|
ChatClient,
|
||||||
SlowModeRateLimiter,
|
SlowModeRateLimiter,
|
||||||
} from "dank-twitch-irc";
|
} = require("dank-twitch-irc");
|
||||||
|
|
||||||
export let client = new ChatClient({
|
let client = new ChatClient({
|
||||||
username: process.env.TWITCH_USERNAME,
|
username: process.env.TWITCH_USERNAME,
|
||||||
password: process.env.TWITCH_PASSWORD,
|
password: process.env.TWITCH_PASSWORD,
|
||||||
|
|
||||||
|
@ -14,3 +14,5 @@ export let client = new ChatClient({
|
||||||
|
|
||||||
client.use(new SlowModeRateLimiter(client));
|
client.use(new SlowModeRateLimiter(client));
|
||||||
client.use(new AlternateMessageModifier(client));
|
client.use(new AlternateMessageModifier(client));
|
||||||
|
|
||||||
|
module.exports = { client };
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import fs from "fs";
|
const fs = require("fs");
|
||||||
|
|
||||||
const command = {
|
const command = {
|
||||||
name: "commands",
|
name: "commands",
|
||||||
|
@ -17,4 +17,4 @@ const command = {
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
export default { command };
|
module.exports = { command };
|
||||||
|
|
|
@ -20,4 +20,4 @@ const command = {
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
export default { command };
|
module.exports = { command };
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
import fetch from "node-fetch";
|
|
||||||
|
|
||||||
const command = {
|
const command = {
|
||||||
name: "fm",
|
name: "fm",
|
||||||
desc: "get last played track from last.fm with your username",
|
desc: "get last played track from last.fm with your username",
|
||||||
|
@ -37,4 +35,4 @@ const command = {
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
export default { command };
|
module.exports = { command };
|
||||||
|
|
|
@ -18,4 +18,4 @@ const command = {
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
export default { command };
|
module.exports = { command };
|
||||||
|
|
|
@ -20,4 +20,4 @@ const command = {
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
export default { command };
|
module.exports = { command };
|
||||||
|
|
|
@ -20,4 +20,4 @@ const command = {
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
export default { command };
|
module.exports = { command };
|
||||||
|
|
|
@ -45,4 +45,4 @@ const command = {
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
export default { command };
|
module.exports = { command };
|
||||||
|
|
|
@ -11,4 +11,4 @@ const command = {
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
export default { command };
|
module.exports = { command };
|
||||||
|
|
|
@ -32,4 +32,4 @@ const command = {
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
export default { command };
|
module.exports = { command };
|
||||||
|
|
|
@ -26,4 +26,4 @@ const command = {
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
export default { command };
|
module.exports = { command };
|
||||||
|
|
|
@ -33,4 +33,4 @@ const command = {
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
export default { command };
|
module.exports = { command };
|
||||||
|
|
|
@ -25,4 +25,4 @@ const command = {
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
export default { command };
|
module.exports = { command };
|
||||||
|
|
|
@ -29,4 +29,4 @@ const command = {
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
export default { command };
|
module.exports = { command };
|
||||||
|
|
|
@ -32,4 +32,4 @@ const command = {
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
export default { command };
|
module.exports = { command };
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
import fetch from "node-fetch";
|
|
||||||
|
|
||||||
const command = {
|
const command = {
|
||||||
name: "weather",
|
name: "weather",
|
||||||
desc: "get the weather from wttr.in",
|
desc: "get the weather from wttr.in",
|
||||||
|
@ -36,4 +34,4 @@ const command = {
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
export default { command };
|
module.exports = { command };
|
||||||
|
|
|
@ -31,4 +31,4 @@ const command = {
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
export default { command };
|
module.exports = { command };
|
||||||
|
|
9
index.js
9
index.js
|
@ -1,7 +1,8 @@
|
||||||
import { client } from "./clients/twitch.js";
|
const { client } = require("./clients/twitch.js");
|
||||||
import { getCommands } from "./utils/commands.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("ready", async () => console.log("Successfully connected to chat"));
|
||||||
client.on("close", async (error) => {
|
client.on("close", async (error) => {
|
||||||
if (error != null) {
|
if (error != null) {
|
||||||
|
@ -19,6 +20,8 @@ client.on("PRIVMSG", async (msg) => {
|
||||||
splitted.splice(1, 1);
|
splitted.splice(1, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
console.log(commands);
|
||||||
|
|
||||||
if (splitted[0] === "%") {
|
if (splitted[0] === "%") {
|
||||||
try {
|
try {
|
||||||
await commands[splitted[1]].run(client, msg, splitted);
|
await commands[splitted[1]].run(client, msg, splitted);
|
||||||
|
|
|
@ -9,10 +9,8 @@
|
||||||
"keywords": [],
|
"keywords": [],
|
||||||
"author": "",
|
"author": "",
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"type": "module",
|
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"dank-twitch-irc": "^4.3.0",
|
"dank-twitch-irc": "^4.3.0",
|
||||||
"node-fetch": "^3.3.0",
|
|
||||||
"nodemon": "^2.0.20"
|
"nodemon": "^2.0.20"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,12 +2,10 @@ lockfileVersion: 5.4
|
||||||
|
|
||||||
specifiers:
|
specifiers:
|
||||||
dank-twitch-irc: ^4.3.0
|
dank-twitch-irc: ^4.3.0
|
||||||
node-fetch: ^3.3.0
|
|
||||||
nodemon: ^2.0.20
|
nodemon: ^2.0.20
|
||||||
|
|
||||||
dependencies:
|
dependencies:
|
||||||
dank-twitch-irc: 4.3.0
|
dank-twitch-irc: 4.3.0
|
||||||
node-fetch: 3.3.0
|
|
||||||
nodemon: 2.0.20
|
nodemon: 2.0.20
|
||||||
|
|
||||||
packages:
|
packages:
|
||||||
|
@ -115,11 +113,6 @@ packages:
|
||||||
- utf-8-validate
|
- utf-8-validate
|
||||||
dev: false
|
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:
|
/debug-logger/0.4.1:
|
||||||
resolution: {integrity: sha512-bLX6pxuWO6KMXBRk6vpLgHqWXiuLbKp8kLL/wNEA4rgU8wsNLaw3UNz0NfOi1bcN0JwjFwSfxhldzU5Bc6P5RQ==}
|
resolution: {integrity: sha512-bLX6pxuWO6KMXBRk6vpLgHqWXiuLbKp8kLL/wNEA4rgU8wsNLaw3UNz0NfOi1bcN0JwjFwSfxhldzU5Bc6P5RQ==}
|
||||||
dependencies:
|
dependencies:
|
||||||
|
@ -182,14 +175,6 @@ packages:
|
||||||
resolution: {integrity: sha512-8guHBZCwKnFhYdHr2ysuRWErTwhoN2X8XELRlrRwpmfeY2jjuUN4taQMsULKUVo1K4DvZl+0pgfyoysHxvmvEw==}
|
resolution: {integrity: sha512-8guHBZCwKnFhYdHr2ysuRWErTwhoN2X8XELRlrRwpmfeY2jjuUN4taQMsULKUVo1K4DvZl+0pgfyoysHxvmvEw==}
|
||||||
dev: false
|
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:
|
/fill-range/7.0.1:
|
||||||
resolution: {integrity: sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==}
|
resolution: {integrity: sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==}
|
||||||
engines: {node: '>=8'}
|
engines: {node: '>=8'}
|
||||||
|
@ -197,13 +182,6 @@ packages:
|
||||||
to-regex-range: 5.0.1
|
to-regex-range: 5.0.1
|
||||||
dev: false
|
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:
|
/fsevents/2.3.2:
|
||||||
resolution: {integrity: sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==}
|
resolution: {integrity: sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==}
|
||||||
engines: {node: ^8.16.0 || ^10.6.0 || >=11.0.0}
|
engines: {node: ^8.16.0 || ^10.6.0 || >=11.0.0}
|
||||||
|
@ -292,20 +270,6 @@ packages:
|
||||||
resolution: {integrity: sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==}
|
resolution: {integrity: sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==}
|
||||||
dev: false
|
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:
|
/nodemon/2.0.20:
|
||||||
resolution: {integrity: sha512-Km2mWHKKY5GzRg6i1j5OxOHQtuvVsgskLfigG25yTtbyfRGn/GNvIbRyOf1PSCKJ2aT/58TiuUsuOU5UToVViw==}
|
resolution: {integrity: sha512-Km2mWHKKY5GzRg6i1j5OxOHQtuvVsgskLfigG25yTtbyfRGn/GNvIbRyOf1PSCKJ2aT/58TiuUsuOU5UToVViw==}
|
||||||
engines: {node: '>=8.10.0'}
|
engines: {node: '>=8.10.0'}
|
||||||
|
@ -477,11 +441,6 @@ packages:
|
||||||
resolution: {integrity: sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==}
|
resolution: {integrity: sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==}
|
||||||
dev: false
|
dev: false
|
||||||
|
|
||||||
/web-streams-polyfill/3.2.1:
|
|
||||||
resolution: {integrity: sha512-e0MO3wdXWKrLbL0DgGnUV7WHVuw9OUvL4hjgnPkIeEvESk74gAITi5G606JtZPp39cd8HA9VQzCIvA49LpPN5Q==}
|
|
||||||
engines: {node: '>= 8'}
|
|
||||||
dev: false
|
|
||||||
|
|
||||||
/wrappy/1.0.2:
|
/wrappy/1.0.2:
|
||||||
resolution: {integrity: sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==}
|
resolution: {integrity: sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==}
|
||||||
dev: false
|
dev: false
|
||||||
|
|
|
@ -1,16 +1,18 @@
|
||||||
import fs from "fs";
|
const fs = require("fs");
|
||||||
|
|
||||||
export async function getCommands() {
|
function getCommands() {
|
||||||
const commands = {};
|
const commands = {};
|
||||||
const commandFiles = fs
|
const commandFiles = fs
|
||||||
.readdirSync("./commands")
|
.readdirSync("./commands")
|
||||||
.map((file) => file.replace(".js", ""));
|
.map((file) => file.replace(".js", ""));
|
||||||
|
|
||||||
for (let file of commandFiles) {
|
for (let file of commandFiles) {
|
||||||
await import(`../commands/${file}.js`).then(
|
import(`../commands/${file}.js`).then(
|
||||||
(cmd) => (commands[file] = cmd.default.command)
|
(cmd) => (commands[file] = cmd.default.command)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return commands;
|
return commands;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
module.exports = { getCommands };
|
||||||
|
|
Loading…
Reference in a new issue