command descriptions and some error handling
This commit is contained in:
parent
f3ec643cbc
commit
1e81dfba6a
9 changed files with 34 additions and 3 deletions
|
@ -1,8 +1,11 @@
|
|||
const command = {
|
||||
name: "fill",
|
||||
desc: "fill the chat with something",
|
||||
run: async (client, msg, splitted) => {
|
||||
if (!splitted[2]) {
|
||||
client.say(msg.channelName, `${msg.displayName}, Supply an arg PoroSad`);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
let str = "";
|
||||
|
|
|
@ -2,12 +2,14 @@ import fetch from "node-fetch";
|
|||
|
||||
const command = {
|
||||
name: "fm",
|
||||
desc: "get last played track from last.fm with your username",
|
||||
run: async (client, msg, splitted) => {
|
||||
if (splitted[2] === undefined) {
|
||||
client.say(
|
||||
msg.channelName,
|
||||
`${msg.displayName}, supply your Last.FM username PoroSad`
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
const data = await fetch(
|
||||
|
@ -21,6 +23,7 @@ const command = {
|
|||
|
||||
if (data === undefined) {
|
||||
client.say(msg.channelName, `${msg.displayName}, Invalid user PoroSad`);
|
||||
return;
|
||||
}
|
||||
|
||||
await client
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
const command = {
|
||||
name: "love",
|
||||
desc: "get the amount of love between two people!",
|
||||
run: async (client, msg, splitted) => {
|
||||
if (splitted[2] === undefined || splitted[3] === undefined) {
|
||||
client.say(msg.channelName, `${msg.displayName}, supply 2 args PoroSad`);
|
||||
return;
|
||||
}
|
||||
|
||||
await client
|
||||
|
|
|
@ -1,7 +1,10 @@
|
|||
const command = {
|
||||
name: "massping",
|
||||
desc: "ping every chatter in the room (this one also blocks the thread until it's done)",
|
||||
run: async (client, msg) => {
|
||||
const data = await fetch(`https://tmi.twitch.tv/group/user/elis/chatters`)
|
||||
const data = await fetch(
|
||||
`https://tmi.twitch.tv/group/user/${msg.channelName}/chatters`
|
||||
)
|
||||
.then((res) => res.json())
|
||||
.then((data) => {
|
||||
return data.chatters;
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
const command = {
|
||||
name: "ping",
|
||||
desc: "uptime",
|
||||
run: async (client, msg) => {
|
||||
await client
|
||||
.say(
|
||||
|
|
|
@ -1,11 +1,18 @@
|
|||
const command = {
|
||||
name: "pyramid",
|
||||
desc: "make a pyramid (this blocks the thread and no other command will execute until it's done)",
|
||||
run: async (client, msg, splitted) => {
|
||||
if (isNaN(splitted[2]) || splitted[3] === undefined) {
|
||||
if (
|
||||
isNaN(splitted[2]) ||
|
||||
splitted[2] === undefined ||
|
||||
splitted[3] === undefined
|
||||
) {
|
||||
client.say(
|
||||
msg.channelName,
|
||||
`${msg.displayName}, Second arg needs to be a valid number and third arg needs to exist PoroSad`
|
||||
);
|
||||
|
||||
return;
|
||||
}
|
||||
let arr = [];
|
||||
for (let i = 0; i < parseInt(splitted[2]); i++) {
|
||||
|
|
|
@ -2,12 +2,15 @@ import fetch from "node-fetch";
|
|||
|
||||
const command = {
|
||||
name: "trending",
|
||||
desc: "get the most trending video in youtube by region",
|
||||
run: async (client, msg, splitted) => {
|
||||
if (!splitted[2]) {
|
||||
await client.say(
|
||||
msg.channelName,
|
||||
`${msg.displayName}, Please append a region PoroSad`
|
||||
);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
const data = await fetch(
|
||||
|
@ -18,7 +21,9 @@ const command = {
|
|||
|
||||
if (data[0] === undefined) {
|
||||
client.say(msg.channelName, `${msg.displayName}, Invalid region PoroSad`);
|
||||
return;
|
||||
}
|
||||
|
||||
await client
|
||||
.say(
|
||||
msg.channelName,
|
||||
|
|
|
@ -2,12 +2,15 @@ import fetch from "node-fetch";
|
|||
|
||||
const command = {
|
||||
name: "weather",
|
||||
desc: "get the weather from wttr.in",
|
||||
run: async (client, msg, splitted) => {
|
||||
if (splitted[2] === undefined) {
|
||||
client.say(
|
||||
msg.channelName,
|
||||
`${msg.displayName}, supply a location PoroSad`
|
||||
);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
const data = await fetch(`https://wttr.in/${splitted[2]}?format=j1`)
|
||||
|
@ -22,6 +25,8 @@ const command = {
|
|||
msg.channelName,
|
||||
`${msg.displayName}, Invalid location PoroSad`
|
||||
);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
await client
|
||||
|
|
4
index.js
4
index.js
|
@ -20,7 +20,9 @@ client.on("PRIVMSG", async (msg) => {
|
|||
if (splitted[0] === "%") {
|
||||
import(`./commands/${splitted[1]}.js`)
|
||||
.then((command) => command.default.command.run(client, msg, splitted))
|
||||
.catch((err) => console.log(err));
|
||||
.catch(() =>
|
||||
client.say(msg.channelName, `${msg.displayName}, not a command PoroSad`)
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in a new issue