diff --git a/.gitignore b/.gitignore index b512c09..49b0341 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ -node_modules \ No newline at end of file +node_modules +ecosystem.config.js \ No newline at end of file diff --git a/commands/commands.js b/commands/commands.js index e440080..9cc2ed8 100644 --- a/commands/commands.js +++ b/commands/commands.js @@ -3,6 +3,7 @@ const fs = require("fs"); const command = { name: "commands", desc: "get list of commands", + restricted: false, run: async (client, msg) => { const commandFiles = fs .readdirSync("./commands") diff --git a/commands/fill.js b/commands/fill.js index 0eb6ab0..1e0408d 100644 --- a/commands/fill.js +++ b/commands/fill.js @@ -1,6 +1,7 @@ const command = { name: "fill", desc: "fill the chat with something", + restricted: false, run: async (client, msg, splitted) => { if (!splitted[2]) { client diff --git a/commands/fm.js b/commands/fm.js index e8cddc2..73788ea 100644 --- a/commands/fm.js +++ b/commands/fm.js @@ -1,6 +1,7 @@ const command = { name: "fm", desc: "get last played track from last.fm with your username", + restricted: false, run: async (client, msg, splitted) => { if (splitted[2] === undefined) { client.say( diff --git a/commands/hn.js b/commands/hn.js index 739ab0a..1153b84 100644 --- a/commands/hn.js +++ b/commands/hn.js @@ -1,6 +1,7 @@ const command = { name: "hn", desc: "fetch hacker news", + restricted: false, run: async (client, msg) => { const data = await fetch( `https://hn.algolia.com/api/v1/search?tags=front_page` diff --git a/commands/join.js b/commands/join.js index db06c99..f81f352 100644 --- a/commands/join.js +++ b/commands/join.js @@ -1,6 +1,7 @@ const command = { name: "join", desc: "make the bot listen to a channel", + restricted: false, run: async (client, msg) => { await client .join(msg.senderUsername) diff --git a/commands/love.js b/commands/love.js index 5dd30bb..3acc504 100644 --- a/commands/love.js +++ b/commands/love.js @@ -1,6 +1,7 @@ const command = { name: "love", desc: "get the amount of love between two people!", + restricted: false, run: async (client, msg, splitted) => { if (splitted[2] === undefined || splitted[3] === undefined) { client.say(msg.channelName, `${msg.displayName}, supply 2 args PoroSad`); diff --git a/commands/mail.js b/commands/mail.js index ee176c3..8612f04 100644 --- a/commands/mail.js +++ b/commands/mail.js @@ -1,6 +1,7 @@ const command = { name: "mail", desc: "temporary email using dropmail.me", + restricted: false, run: async (client, msg, splitted) => { switch (splitted[2]) { case "create": { diff --git a/commands/massping.js b/commands/massping.js index 9a1d294..73d982a 100644 --- a/commands/massping.js +++ b/commands/massping.js @@ -1,6 +1,7 @@ const command = { name: "massping", desc: "ping every chatter in the room (this one also blocks the thread until it's done)", + restricted: true, run: async (client, msg, splitted) => { let channel = msg.channelName; if (splitted[2]) channel = splitted[2]; diff --git a/commands/ping.js b/commands/ping.js index 2221216..9030c56 100644 --- a/commands/ping.js +++ b/commands/ping.js @@ -1,6 +1,7 @@ const command = { name: "ping", desc: "uptime", + restricted: false, run: async (client, msg) => { await client .say( diff --git a/commands/pyramid.js b/commands/pyramid.js index 7d4b42c..b7a7b4a 100644 --- a/commands/pyramid.js +++ b/commands/pyramid.js @@ -1,6 +1,7 @@ const command = { name: "pyramid", desc: "make a pyramid (this blocks the thread and no other command will execute until it's done)", + restricted: true, run: async (client, msg, splitted) => { if ( isNaN(splitted[2]) || diff --git a/commands/rd.js b/commands/rd.js index 19ef8f3..fa57a87 100644 --- a/commands/rd.js +++ b/commands/rd.js @@ -1,6 +1,7 @@ const command = { name: "rd", desc: "get post from reddit subreddit", + restricted: false, run: async (client, msg, splitted) => { const data = await fetch( `https://teddit.namazso.eu/r/${ diff --git a/commands/rl.js b/commands/rl.js index a13976e..3ecd728 100644 --- a/commands/rl.js +++ b/commands/rl.js @@ -1,6 +1,7 @@ const command = { name: "rl", desc: "get a random line from a channel", + restricted: false, run: async (client, msg, splitted) => { const data = await fetch( `https://logs.ivr.fi/channel/${ diff --git a/commands/short.js b/commands/short.js index 3f0da57..bea25c4 100644 --- a/commands/short.js +++ b/commands/short.js @@ -1,6 +1,7 @@ const command = { name: "short", desc: "shorten an url", + restricted: false, run: async (client, msg, splitted) => { if (!splitted[2]) { client diff --git a/commands/sketch.js b/commands/sketch.js index 4781606..cc0e27a 100644 --- a/commands/sketch.js +++ b/commands/sketch.js @@ -1,6 +1,7 @@ const command = { name: "sketch", desc: "make a suspicious link", + restricted: false, run: async (client, msg, splitted) => { if (!splitted[2]) { client.say( diff --git a/commands/twitter.js b/commands/twitter.js index dabbf1a..912f707 100644 --- a/commands/twitter.js +++ b/commands/twitter.js @@ -1,6 +1,7 @@ const command = { name: "twitter", desc: "fetch latest tweet from user", + restricted: false, run: async (client, msg, splitted) => { const data = await fetch( `https://api.rss2json.com/v1/api.json?rss_url=https://nitter.namazso.eu/${ diff --git a/commands/user.js b/commands/user.js index efa355e..0581969 100644 --- a/commands/user.js +++ b/commands/user.js @@ -1,6 +1,7 @@ const command = { name: "user", desc: "get info about a certain user", + restricted: false, run: async (client, msg, splitted) => { const data = await fetch( `https://api.ivr.fi/v2/twitch/user?login=${ diff --git a/commands/weather.js b/commands/weather.js index 89bc5d5..efff6b7 100644 --- a/commands/weather.js +++ b/commands/weather.js @@ -1,6 +1,7 @@ const command = { name: "weather", desc: "get the weather from wttr.in", + restricted: false, run: async (client, msg, splitted) => { if (splitted[2] === undefined) { client diff --git a/commands/yts.js b/commands/yts.js index e6ff41e..5541314 100644 --- a/commands/yts.js +++ b/commands/yts.js @@ -1,6 +1,7 @@ const command = { name: "yts", desc: "search youtube for a video", + restricted: false, run: async (client, msg, splitted) => { if (splitted[2] === undefined) { client @@ -13,10 +14,13 @@ const command = { `https://invidious.epicsite.xyz/api/v1/search?type=video&q=${splitted .slice(2) .join(" ") - .replaceAll(/\W/g, "")}` + .replaceAll("?", "") + .replaceAll("/", "") + .replaceAll("\\", "") + .replaceAll("&", "")}` ) .then((res) => res.json()) - .then((data) => data[Math.floor(Math.random() * data.length)]) + .then((data) => data[0]) .catch((err) => console.log(err)); await client diff --git a/index.js b/index.js index eaa7dfe..79cdc0b 100644 --- a/index.js +++ b/index.js @@ -21,6 +21,18 @@ client.on("PRIVMSG", async (msg) => { if (splitted[0] === process.env.BOT_PREFIX) { try { + if (commands[splitted[1]].restricted) { + if (!msg.badges.hasBroadcaster) { + if (!msg.isMod) { + client.say( + msg.channelName, + `${msg.displayName}, need to be a mod or brodcaster to use` + ); + return; + } + } + } + await commands[splitted[1]].run(client, msg, splitted); } catch (err) { client