command access restriction
This commit is contained in:
parent
9a22ecbeb3
commit
3317cf98a6
|
@ -1 +1,2 @@
|
||||||
node_modules
|
node_modules
|
||||||
|
ecosystem.config.js
|
|
@ -3,6 +3,7 @@ const fs = require("fs");
|
||||||
const command = {
|
const command = {
|
||||||
name: "commands",
|
name: "commands",
|
||||||
desc: "get list of commands",
|
desc: "get list of commands",
|
||||||
|
restricted: false,
|
||||||
run: async (client, msg) => {
|
run: async (client, msg) => {
|
||||||
const commandFiles = fs
|
const commandFiles = fs
|
||||||
.readdirSync("./commands")
|
.readdirSync("./commands")
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
const command = {
|
const command = {
|
||||||
name: "fill",
|
name: "fill",
|
||||||
desc: "fill the chat with something",
|
desc: "fill the chat with something",
|
||||||
|
restricted: false,
|
||||||
run: async (client, msg, splitted) => {
|
run: async (client, msg, splitted) => {
|
||||||
if (!splitted[2]) {
|
if (!splitted[2]) {
|
||||||
client
|
client
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
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",
|
||||||
|
restricted: false,
|
||||||
run: async (client, msg, splitted) => {
|
run: async (client, msg, splitted) => {
|
||||||
if (splitted[2] === undefined) {
|
if (splitted[2] === undefined) {
|
||||||
client.say(
|
client.say(
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
const command = {
|
const command = {
|
||||||
name: "hn",
|
name: "hn",
|
||||||
desc: "fetch hacker news",
|
desc: "fetch hacker news",
|
||||||
|
restricted: false,
|
||||||
run: async (client, msg) => {
|
run: async (client, msg) => {
|
||||||
const data = await fetch(
|
const data = await fetch(
|
||||||
`https://hn.algolia.com/api/v1/search?tags=front_page`
|
`https://hn.algolia.com/api/v1/search?tags=front_page`
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
const command = {
|
const command = {
|
||||||
name: "join",
|
name: "join",
|
||||||
desc: "make the bot listen to a channel",
|
desc: "make the bot listen to a channel",
|
||||||
|
restricted: false,
|
||||||
run: async (client, msg) => {
|
run: async (client, msg) => {
|
||||||
await client
|
await client
|
||||||
.join(msg.senderUsername)
|
.join(msg.senderUsername)
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
const command = {
|
const command = {
|
||||||
name: "love",
|
name: "love",
|
||||||
desc: "get the amount of love between two people!",
|
desc: "get the amount of love between two people!",
|
||||||
|
restricted: false,
|
||||||
run: async (client, msg, splitted) => {
|
run: async (client, msg, splitted) => {
|
||||||
if (splitted[2] === undefined || splitted[3] === undefined) {
|
if (splitted[2] === undefined || splitted[3] === undefined) {
|
||||||
client.say(msg.channelName, `${msg.displayName}, supply 2 args PoroSad`);
|
client.say(msg.channelName, `${msg.displayName}, supply 2 args PoroSad`);
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
const command = {
|
const command = {
|
||||||
name: "mail",
|
name: "mail",
|
||||||
desc: "temporary email using dropmail.me",
|
desc: "temporary email using dropmail.me",
|
||||||
|
restricted: false,
|
||||||
run: async (client, msg, splitted) => {
|
run: async (client, msg, splitted) => {
|
||||||
switch (splitted[2]) {
|
switch (splitted[2]) {
|
||||||
case "create": {
|
case "create": {
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
const command = {
|
const command = {
|
||||||
name: "massping",
|
name: "massping",
|
||||||
desc: "ping every chatter in the room (this one also blocks the thread until it's done)",
|
desc: "ping every chatter in the room (this one also blocks the thread until it's done)",
|
||||||
|
restricted: true,
|
||||||
run: async (client, msg, splitted) => {
|
run: async (client, msg, splitted) => {
|
||||||
let channel = msg.channelName;
|
let channel = msg.channelName;
|
||||||
if (splitted[2]) channel = splitted[2];
|
if (splitted[2]) channel = splitted[2];
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
const command = {
|
const command = {
|
||||||
name: "ping",
|
name: "ping",
|
||||||
desc: "uptime",
|
desc: "uptime",
|
||||||
|
restricted: false,
|
||||||
run: async (client, msg) => {
|
run: async (client, msg) => {
|
||||||
await client
|
await client
|
||||||
.say(
|
.say(
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
const command = {
|
const command = {
|
||||||
name: "pyramid",
|
name: "pyramid",
|
||||||
desc: "make a pyramid (this blocks the thread and no other command will execute until it's done)",
|
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) => {
|
run: async (client, msg, splitted) => {
|
||||||
if (
|
if (
|
||||||
isNaN(splitted[2]) ||
|
isNaN(splitted[2]) ||
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
const command = {
|
const command = {
|
||||||
name: "rd",
|
name: "rd",
|
||||||
desc: "get post from reddit subreddit",
|
desc: "get post from reddit subreddit",
|
||||||
|
restricted: false,
|
||||||
run: async (client, msg, splitted) => {
|
run: async (client, msg, splitted) => {
|
||||||
const data = await fetch(
|
const data = await fetch(
|
||||||
`https://teddit.namazso.eu/r/${
|
`https://teddit.namazso.eu/r/${
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
const command = {
|
const command = {
|
||||||
name: "rl",
|
name: "rl",
|
||||||
desc: "get a random line from a channel",
|
desc: "get a random line from a channel",
|
||||||
|
restricted: false,
|
||||||
run: async (client, msg, splitted) => {
|
run: async (client, msg, splitted) => {
|
||||||
const data = await fetch(
|
const data = await fetch(
|
||||||
`https://logs.ivr.fi/channel/${
|
`https://logs.ivr.fi/channel/${
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
const command = {
|
const command = {
|
||||||
name: "short",
|
name: "short",
|
||||||
desc: "shorten an url",
|
desc: "shorten an url",
|
||||||
|
restricted: false,
|
||||||
run: async (client, msg, splitted) => {
|
run: async (client, msg, splitted) => {
|
||||||
if (!splitted[2]) {
|
if (!splitted[2]) {
|
||||||
client
|
client
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
const command = {
|
const command = {
|
||||||
name: "sketch",
|
name: "sketch",
|
||||||
desc: "make a suspicious link",
|
desc: "make a suspicious link",
|
||||||
|
restricted: false,
|
||||||
run: async (client, msg, splitted) => {
|
run: async (client, msg, splitted) => {
|
||||||
if (!splitted[2]) {
|
if (!splitted[2]) {
|
||||||
client.say(
|
client.say(
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
const command = {
|
const command = {
|
||||||
name: "twitter",
|
name: "twitter",
|
||||||
desc: "fetch latest tweet from user",
|
desc: "fetch latest tweet from user",
|
||||||
|
restricted: false,
|
||||||
run: async (client, msg, splitted) => {
|
run: async (client, msg, splitted) => {
|
||||||
const data = await fetch(
|
const data = await fetch(
|
||||||
`https://api.rss2json.com/v1/api.json?rss_url=https://nitter.namazso.eu/${
|
`https://api.rss2json.com/v1/api.json?rss_url=https://nitter.namazso.eu/${
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
const command = {
|
const command = {
|
||||||
name: "user",
|
name: "user",
|
||||||
desc: "get info about a certain user",
|
desc: "get info about a certain user",
|
||||||
|
restricted: false,
|
||||||
run: async (client, msg, splitted) => {
|
run: async (client, msg, splitted) => {
|
||||||
const data = await fetch(
|
const data = await fetch(
|
||||||
`https://api.ivr.fi/v2/twitch/user?login=${
|
`https://api.ivr.fi/v2/twitch/user?login=${
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
const command = {
|
const command = {
|
||||||
name: "weather",
|
name: "weather",
|
||||||
desc: "get the weather from wttr.in",
|
desc: "get the weather from wttr.in",
|
||||||
|
restricted: false,
|
||||||
run: async (client, msg, splitted) => {
|
run: async (client, msg, splitted) => {
|
||||||
if (splitted[2] === undefined) {
|
if (splitted[2] === undefined) {
|
||||||
client
|
client
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
const command = {
|
const command = {
|
||||||
name: "yts",
|
name: "yts",
|
||||||
desc: "search youtube for a video",
|
desc: "search youtube for a video",
|
||||||
|
restricted: false,
|
||||||
run: async (client, msg, splitted) => {
|
run: async (client, msg, splitted) => {
|
||||||
if (splitted[2] === undefined) {
|
if (splitted[2] === undefined) {
|
||||||
client
|
client
|
||||||
|
@ -13,10 +14,13 @@ const command = {
|
||||||
`https://invidious.epicsite.xyz/api/v1/search?type=video&q=${splitted
|
`https://invidious.epicsite.xyz/api/v1/search?type=video&q=${splitted
|
||||||
.slice(2)
|
.slice(2)
|
||||||
.join(" ")
|
.join(" ")
|
||||||
.replaceAll(/\W/g, "")}`
|
.replaceAll("?", "")
|
||||||
|
.replaceAll("/", "")
|
||||||
|
.replaceAll("\\", "")
|
||||||
|
.replaceAll("&", "")}`
|
||||||
)
|
)
|
||||||
.then((res) => res.json())
|
.then((res) => res.json())
|
||||||
.then((data) => data[Math.floor(Math.random() * data.length)])
|
.then((data) => data[0])
|
||||||
.catch((err) => console.log(err));
|
.catch((err) => console.log(err));
|
||||||
|
|
||||||
await client
|
await client
|
||||||
|
|
12
index.js
12
index.js
|
@ -21,6 +21,18 @@ client.on("PRIVMSG", async (msg) => {
|
||||||
|
|
||||||
if (splitted[0] === process.env.BOT_PREFIX) {
|
if (splitted[0] === process.env.BOT_PREFIX) {
|
||||||
try {
|
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);
|
await commands[splitted[1]].run(client, msg, splitted);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
client
|
client
|
||||||
|
|
Loading…
Reference in New Issue