added checking if command requires mod, added vanish and google command (very unstable) and also setup redis for future things
This commit is contained in:
parent
f599103f48
commit
9d4a35fc44
6 changed files with 123 additions and 1 deletions
4
clients/redis.js
Normal file
4
clients/redis.js
Normal file
|
@ -0,0 +1,4 @@
|
|||
const Redis = require("ioredis");
|
||||
const redis = new Redis();
|
||||
|
||||
module.exports = { redis };
|
27
commands/google.js
Normal file
27
commands/google.js
Normal file
|
@ -0,0 +1,27 @@
|
|||
const command = {
|
||||
name: "google",
|
||||
desc: "google search",
|
||||
restricted: false,
|
||||
mod: false,
|
||||
run: async (client, msg, splitted) => {
|
||||
const data = await fetch(
|
||||
`https://searx.chocoflan.net/search?q=${splitted[2]}&format=json&engines=google`
|
||||
)
|
||||
.then((res) => res.json())
|
||||
.catch((err) => console.log(err));
|
||||
|
||||
if (data.results.length < 1) {
|
||||
await client.say(
|
||||
msg.channelName,
|
||||
`${msg.displayName}, no results found or api is down`
|
||||
);
|
||||
}
|
||||
|
||||
await client.say(
|
||||
msg.channelName,
|
||||
`${msg.displayName}, First result for query ${splitted[2]}: ${data.title} - ${data.content} ${data.url}`
|
||||
);
|
||||
},
|
||||
};
|
||||
|
||||
module.exports = { command };
|
11
commands/vanish.js
Normal file
11
commands/vanish.js
Normal file
|
@ -0,0 +1,11 @@
|
|||
const command = {
|
||||
name: "vanish",
|
||||
desc: "disapper from sight",
|
||||
restricted: false,
|
||||
mod: true,
|
||||
run: async (client, msg) => {
|
||||
await client.timeout(msg.channelName, msg.senderUsername, 1);
|
||||
},
|
||||
};
|
||||
|
||||
module.exports = { command };
|
24
index.js
24
index.js
|
@ -1,4 +1,5 @@
|
|||
const { client } = require("./clients/twitch.js");
|
||||
const { redis } = require("./clients/redis.js");
|
||||
const { getCommands } = require("./utils/commands.js");
|
||||
const commands = getCommands();
|
||||
|
||||
|
@ -33,12 +34,29 @@ client.on("PRIVMSG", async (msg) => {
|
|||
}
|
||||
}
|
||||
|
||||
if (
|
||||
!client.userStateTracker.channelStates[msg.channelName].badges
|
||||
.hasBroadcaster
|
||||
) {
|
||||
if (
|
||||
commands[splitted[1]].mod &&
|
||||
!client.userStateTracker.channelStates[msg.channelName].isMod
|
||||
) {
|
||||
client.say(
|
||||
msg.channelName,
|
||||
`${msg.displayName}, bot needs to be a mod or brodcaster to use`
|
||||
);
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
await commands[splitted[1]].run(client, msg, splitted);
|
||||
} catch (err) {
|
||||
client
|
||||
.say(
|
||||
msg.channelName,
|
||||
`${msg.displayName}, not a command or something went wrong`
|
||||
`${msg.displayName}, not a command or something went wrong ${err}`
|
||||
)
|
||||
.catch((err) => console.log(err));
|
||||
}
|
||||
|
@ -47,3 +65,7 @@ client.on("PRIVMSG", async (msg) => {
|
|||
|
||||
client.connect();
|
||||
client.joinAll([process.env.TWITCH_USERNAME, "rollinjuusto"]);
|
||||
|
||||
process.on("SIGINT", () => {
|
||||
process.exit(1);
|
||||
});
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"dank-twitch-irc": "^4.3.0",
|
||||
"ioredis": "^5.3.0",
|
||||
"nodemon": "^2.0.20"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,14 +2,20 @@ lockfileVersion: 5.4
|
|||
|
||||
specifiers:
|
||||
dank-twitch-irc: ^4.3.0
|
||||
ioredis: ^5.3.0
|
||||
nodemon: ^2.0.20
|
||||
|
||||
dependencies:
|
||||
dank-twitch-irc: 4.3.0
|
||||
ioredis: 5.3.0
|
||||
nodemon: 2.0.20
|
||||
|
||||
packages:
|
||||
|
||||
/@ioredis/commands/1.2.0:
|
||||
resolution: {integrity: sha512-Sx1pU8EM64o2BrqNpEO1CNLtKQwyhuXuqyfH7oGKCk+1a33d2r5saW8zNwm3j6BTExtjrv2BxTgzzkMwts6vGg==}
|
||||
dev: false
|
||||
|
||||
/@types/debug/4.1.7:
|
||||
resolution: {integrity: sha512-9AonUzyTjXXhEOa0DnqpzZi6VHlqKMswga9EXjpXnnqxwLtdvPPtlO8evrI5D9S6asFRCQ6v+wpiUKbw+vKqyg==}
|
||||
dependencies:
|
||||
|
@ -85,6 +91,11 @@ packages:
|
|||
fsevents: 2.3.2
|
||||
dev: false
|
||||
|
||||
/cluster-key-slot/1.1.2:
|
||||
resolution: {integrity: sha512-RMr0FhtfXemyinomL4hrWcYJxmX6deFdCxpJzhDttxgO1+bcCnkk+9drydLVDmAMG7NE6aN/fl4F7ucU/90gAA==}
|
||||
engines: {node: '>=0.10.0'}
|
||||
dev: false
|
||||
|
||||
/concat-map/0.0.1:
|
||||
resolution: {integrity: sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==}
|
||||
dev: false
|
||||
|
@ -156,6 +167,11 @@ packages:
|
|||
ms: 2.1.2
|
||||
dev: false
|
||||
|
||||
/denque/2.1.0:
|
||||
resolution: {integrity: sha512-HVQE3AAb/pxF8fQAoiqpvg9i3evqug3hoiwakOyZAwJm+6vZehbkYXZ0l4JxS+I3QxM97v5aaRNhj8v5oBhekw==}
|
||||
engines: {node: '>=0.10'}
|
||||
dev: false
|
||||
|
||||
/duplexify/4.1.2:
|
||||
resolution: {integrity: sha512-fz3OjcNCHmRP12MJoZMPglx8m4rrFP8rovnk4vT8Fs+aonZoCwGg10dSsQsfP/E62eZcPTMSMP6686fu9Qlqtw==}
|
||||
dependencies:
|
||||
|
@ -210,6 +226,23 @@ packages:
|
|||
resolution: {integrity: sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==}
|
||||
dev: false
|
||||
|
||||
/ioredis/5.3.0:
|
||||
resolution: {integrity: sha512-Id9jKHhsILuIZpHc61QkagfVdUj2Rag5GzG1TGEvRNeM7dtTOjICgjC+tvqYxi//PuX2wjQ+Xjva2ONBuf92Pw==}
|
||||
engines: {node: '>=12.22.0'}
|
||||
dependencies:
|
||||
'@ioredis/commands': 1.2.0
|
||||
cluster-key-slot: 1.1.2
|
||||
debug: 4.3.4
|
||||
denque: 2.1.0
|
||||
lodash.defaults: 4.2.0
|
||||
lodash.isarguments: 3.1.0
|
||||
redis-errors: 1.2.0
|
||||
redis-parser: 3.0.0
|
||||
standard-as-callback: 2.1.0
|
||||
transitivePeerDependencies:
|
||||
- supports-color
|
||||
dev: false
|
||||
|
||||
/is-binary-path/2.1.0:
|
||||
resolution: {integrity: sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw==}
|
||||
engines: {node: '>=8'}
|
||||
|
@ -238,6 +271,14 @@ packages:
|
|||
resolution: {integrity: sha512-TwuEnCnxbc3rAvhf/LbG7tJUDzhqXyFnv3dtzLOPgCG/hODL7WFnsbwktkD7yUV0RrreP/l1PALq/YSg6VvjlA==}
|
||||
dev: false
|
||||
|
||||
/lodash.defaults/4.2.0:
|
||||
resolution: {integrity: sha512-qjxPLHd3r5DnsdGacqOMU6pb/avJzdh9tFX2ymgoZE27BmjXrNy/y4LoaiTeAb+O3gL8AfpJGtqfX/ae2leYYQ==}
|
||||
dev: false
|
||||
|
||||
/lodash.isarguments/3.1.0:
|
||||
resolution: {integrity: sha512-chi4NHZlZqZD18a0imDHnZPrDeBbTtVN7GXMwuGdRH9qotxAjYs3aVLKc7zNOG9eddR5Ksd8rvFEBc9SsggPpg==}
|
||||
dev: false
|
||||
|
||||
/lodash.pickby/4.6.0:
|
||||
resolution: {integrity: sha512-AZV+GsS/6ckvPOVQPXSiFFacKvKB4kOQu6ynt9wz0F3LO4R9Ij4K1ddYsIytDpSgLz88JHd9P+oaLeej5/Sl7Q==}
|
||||
dev: false
|
||||
|
@ -352,6 +393,18 @@ packages:
|
|||
picomatch: 2.3.1
|
||||
dev: false
|
||||
|
||||
/redis-errors/1.2.0:
|
||||
resolution: {integrity: sha512-1qny3OExCf0UvUV/5wpYKf2YwPcOqXzkwKKSmKHiE6ZMQs5heeE/c8eXK+PNllPvmjgAbfnsbpkGZWy8cBpn9w==}
|
||||
engines: {node: '>=4'}
|
||||
dev: false
|
||||
|
||||
/redis-parser/3.0.0:
|
||||
resolution: {integrity: sha512-DJnGAeenTdpMEH6uAJRK/uiyEIH9WVsUmoLwzudwGJUwZPp80PDBWPHXSAGNPwNvIXAbe7MSUB1zQFugFml66A==}
|
||||
engines: {node: '>=4'}
|
||||
dependencies:
|
||||
redis-errors: 1.2.0
|
||||
dev: false
|
||||
|
||||
/safe-buffer/5.2.1:
|
||||
resolution: {integrity: sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==}
|
||||
dev: false
|
||||
|
@ -398,6 +451,10 @@ packages:
|
|||
readable-stream: 3.6.0
|
||||
dev: false
|
||||
|
||||
/standard-as-callback/2.1.0:
|
||||
resolution: {integrity: sha512-qoRRSyROncaz1z0mvYqIE4lCd9p2R90i6GxW3uZv5ucSu8tU7B5HXUP1gG8pVZsYNVaXjk8ClXHPttLyxAL48A==}
|
||||
dev: false
|
||||
|
||||
/stream-shift/1.0.1:
|
||||
resolution: {integrity: sha512-AiisoFqQ0vbGcZgQPY1cdP2I76glaVA/RauYR4G4thNFgkTqr90yXTo4LYX60Jl+sIlPNHHdGSwo01AvbKUSVQ==}
|
||||
dev: false
|
||||
|
|
Loading…
Reference in a new issue