twitch_bot/commands/user.js

37 lines
1.1 KiB
JavaScript

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=${
splitted[2] ? splitted[2] : msg.displayName
}`
)
.then((res) => res.json())
.then((data) => data[0])
.catch((err) => console.log(err));
await client
.say(
msg.channelName,
`${msg.displayName}, information about user ${
data.displayName
}: Created at: ${new Date(data.createdAt).toLocaleString()}, ${
data.banned ? `Banned: yes; Reason: ${data.banReason}` : ""
} ${
data.lastBroadcast.startedAt
? `Last stream: ${data.lastBroadcast.title}; ${Math.floor(
(new Date().getTime() -
new Date(data.lastBroadcast.startedAt).getTime()) /
(1000 * 3600 * 24)
)} days ago`
: ""
}`
)
.catch((err) => console.log(err));
},
};
module.exports = { command };