setup husky

This commit is contained in:
Cynthia Foxwell 2022-12-18 12:37:00 -07:00
parent f9046a1a8b
commit 87b3063611
8 changed files with 43 additions and 16 deletions

View file

@ -28,5 +28,6 @@ module.exports = {
globals: {
hf: true,
BigInt: true, // lol eslint
fetch: true,
},
};

1
.husky/.gitignore vendored Normal file
View file

@ -0,0 +1 @@
_

4
.husky/pre-commit Executable file
View file

@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"
node_modules/.bin/eslint . && node_modules/.bin/prettier --check **/*.js

View file

@ -4,7 +4,8 @@
"description": "Discord bot",
"main": "src/index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
"test": "echo \"Error: no test specified\" && exit 1",
"prepare": "husky install"
},
"repository": {
"type": "git",
@ -32,6 +33,7 @@
},
"devDependencies": {
"eslint": "^7.26.0",
"husky": "^8.0.2",
"prettier": "^2.3.0"
}
}

View file

@ -7,6 +7,7 @@ specifiers:
dumpy: github:Cynosphere/dumpy.js
eslint: ^7.26.0
google-images: ^2.1.0
husky: ^8.0.2
jimp: ^0.16.1
murmurhash: ^2.0.0
node-ffprobe: ^3.0.0
@ -32,6 +33,7 @@ dependencies:
devDependencies:
eslint: 7.26.0
husky: 8.0.2
prettier: 2.3.0
packages:
@ -1384,6 +1386,12 @@ packages:
- supports-color
dev: false
/husky/8.0.2:
resolution: {integrity: sha512-Tkv80jtvbnkK3mYWxPZePGFpQ/tT3HNSs/sasF9P2YfkMezDl3ON37YN6jUUI4eTg5LcyVynlb6r4eyvOmspvg==}
engines: {node: '>=14'}
hasBin: true
dev: true
/iconv-lite/0.4.24:
resolution: {integrity: sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==}
engines: {node: '>=0.10.0'}
@ -1743,11 +1751,6 @@ packages:
resolution: {integrity: sha512-CvkDw2OEnme7ybCykJpVcKH+uAOLV2qLqiyla128dN9TkEWfrYmxG6C2boDe5KcNQqZF3orkqzGgOMvZ/JNekA==}
dev: false
/node-fetch/2.6.1:
resolution: {integrity: sha512-V4aYg89jEoVRxRb2fJdAg8FHvI7cEyYdVAh94HH0UIK8oJxUfkjlDQN9RbMx+bEjP7+ggMiFRprSti032Oipxw==}
engines: {node: 4.x || >=6.0.0}
dev: false
/node-fetch/2.6.7:
resolution: {integrity: sha512-ZjMPFEfVx5j+y2yF35Kzx5sF7kDzxuDj6ziH4FFbOp87zKDZNx8yExJIb05OGF4Nlt9IHFIMBkRl41VdvcNdbQ==}
engines: {node: 4.x || >=6.0.0}
@ -2723,5 +2726,7 @@ packages:
color: 3.2.1
gifwrap: 0.9.2
jimp: 0.16.1
node-fetch: 2.6.1
node-fetch: 2.6.7
transitivePeerDependencies:
- encoding
dev: false

View file

@ -59,7 +59,12 @@ bot.on("messageCreate", async (msg) => {
});
bot.on("messageUpdate", (msg, oldMsg) => {
const oneDay = Date.now() - 86400000;
if (msg.timestamp > oneDay && !msg.hasRan && oldMsg && oldMsg.content !== msg.content) {
if (
msg.timestamp > oneDay &&
!msg.hasRan &&
oldMsg &&
oldMsg.content !== msg.content
) {
CommandDispatcher(msg);
}
});

View file

@ -1,5 +1,6 @@
const {formatTime} = require("../lib/utils.js");
const GUILD_ID = "300436792916836352";
const CHANNEL_ID = "353018352580689930";
const THREAD_ID = "1054106209273253888";
const MESSAGE_ID = "1054109813132509245";
@ -14,7 +15,9 @@ async function updateNowPlaying() {
playing = await fetch("http://anonradio.net/playing").then((res) =>
res.text()
);
} catch (err) {}
} catch (err) {
//
}
}
let schedule;
try {
@ -26,7 +29,9 @@ async function updateNowPlaying() {
schedule = await fetch("http://anonradio.net/schedule/").then((res) =>
res.text()
);
} catch (err) {}
} catch (err) {
//
}
}
if (!playing || !schedule) return;
@ -35,9 +40,9 @@ async function updateNowPlaying() {
lines = lines.slice(4, lines.length - 2);
const line = lines[0];
const [_, time, id, name] = line.match(/^(.{3,4} .{4})\s+(.+?) {2}(.+?)$/);
const [_, _time, id, name] = line.match(/^(.{3,4} .{4})\s+(.+?) {2}(.+?)$/);
let liveNow = {name: "ident", id: "aNONradio"};
const liveNow = {name: "ident", id: "aNONradio"};
if (name.includes("<- Live NOW")) {
liveNow.id = id;
@ -88,7 +93,7 @@ async function updateNowPlaying() {
}
}
const content = (`${title}\n${subtitle}\n${openmicTime}`).trim();
const content = `${title}\n${subtitle}\n${openmicTime}`.trim();
const thread = hf.bot.guilds.get(GUILD_ID).threads.get(THREAD_ID);
const msg = await thread.getMessage(MESSAGE_ID);
if (msg.content !== content) {

View file

@ -285,7 +285,9 @@ anonradio.callback = async function () {
playing = await fetch("http://anonradio.net/playing").then((res) =>
res.text()
);
} catch (err) {}
} catch (err) {
//
}
}
let schedule;
try {
@ -297,7 +299,9 @@ anonradio.callback = async function () {
schedule = await fetch("http://anonradio.net/schedule/").then((res) =>
res.text()
);
} catch (err) {}
} catch (err) {
//
}
}
if (!playing || !schedule) return "Failed to fetch schedule.";