Skip to content

Commit

Permalink
Merge branch 'verified-bot-edition-dev' into verified-bot-edition
Browse files Browse the repository at this point in the history
  • Loading branch information
eduardozgz committed Apr 17, 2024
2 parents 038ca7b + 1f835ef commit 0cf2703
Show file tree
Hide file tree
Showing 18 changed files with 318 additions and 516 deletions.
549 changes: 169 additions & 380 deletions package-lock.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
"homepage": "https://member-counter.eduardozgz.com",
"dependencies": {
"@arcanebot/redis-sharder": "github:eduardozgz/redis-sharder",
"@twurple/api": "^5.0.1",
"@twurple/auth": "^5.0.1",
"@twurple/api": "^7.0.6",
"@twurple/auth": "^7.0.6",
"bufferutil": "^4.0.1",
"colorthief": "2.3.2",
"cron": "^1.8.2",
Expand Down
31 changes: 20 additions & 11 deletions src/counters/Twitch.ts
Original file line number Diff line number Diff line change
@@ -1,37 +1,46 @@
import { ApiClient } from "@twurple/api";
import { ClientCredentialsAuthProvider } from "@twurple/auth";
import { AppTokenAuthProvider } from "@twurple/auth";
import getEnv from "../utils/getEnv";
import Counter from "../typings/Counter";

const { TWITCH_CLIENT_ID, TWITCH_CLIENT_SECRET } = getEnv();

const authProvider = new ClientCredentialsAuthProvider(
const authProvider = new AppTokenAuthProvider(
TWITCH_CLIENT_ID,
TWITCH_CLIENT_SECRET
);

const client = new ApiClient({ authProvider });

const TwitchCounter: Counter = {
aliases: ["twitchFollowers", "twitchViews", "twitchChannelName"],
aliases: ["twitchFollowers", "twitchViewers", "twitchChannelName"],
isPremium: true,
isEnabled: true,
lifetime: 60 * 60 * 1000,
execute: async ({ unparsedArgs: userName }) => {
try {
if (!TWITCH_CLIENT_ID) throw new Error("TWITCH_CLIENT_ID not provided");
if (!TWITCH_CLIENT_SECRET)
throw new Error("TWITCH_CLIENT_SECRET not provided");
if (!TWITCH_CLIENT_SECRET) throw new Error("TWITCH_CLIENT_SECRET not provided");

const user = await client.users.getUserByName(userName);
const { views, displayName } = user;
const followers = await client.users
.getFollowsPaginated({ followedUser: user })
.getTotalCount();
const channel = await client.users.getUserByName(userName);
if (!channel) {
return {
twitchFollowers: "User Not Found",
twitchViewers: "User Not Found",
twitchChannelName: "User Not Found"
};
}
const { displayName } = channel;
const stream = await client.streams.getStreamByUserName(userName);
let viewers = "Offline";
if (stream !== null) {
viewers = stream.viewers.toString();
}
const followers = await client.channels.getChannelFollowerCount(channel.id);

return {
twitchFollowers: followers,
twitchViews: views,
twitchViewers: viewers,
twitchChannelName: displayName
};
} catch (e) {
Expand Down
16 changes: 8 additions & 8 deletions src/lang/ca_ES.json
Original file line number Diff line number Diff line change
Expand Up @@ -328,15 +328,15 @@
"{twitchFollowers:ninja} Followers"
]
},
"twitchViews": {
"name": "twitchViews:nickname",
"description": "Amount of views of a Twitch channel",
"detailedDescription": "Counts how many views has a Twitch channel, replace `nickname` with the desired channel name",
"twitchViewers": {
"name": "twitchViewers:nickname",
"description": "Amount of stream viewers",
"detailedDescription": "Counts how many viewers are there on an active stream, replace `nickname` with the desired channel name",
"usage": [
"{twitchViews:nickname}"
"{twitchViewers:nickname}"
],
"example": [
"{twitchViews:ninja} Views"
"{twitchViewers:ninja} Views"
]
},
"twitchChannelName": {
Expand Down Expand Up @@ -848,8 +848,8 @@
"statusCreated": "{CHECK_MARK} Follower counter created"
},
{
"name": "twitchViews",
"template": "{twitchViews:{RESOURCE}} Views",
"name": "twitchViewers",
"template": "Viewers {twitchViewers:{RESOURCE}}",
"statusCreating": "{LOADING} Creating views counter",
"statusCreated": "{CHECK_MARK} Views counter created"
}
Expand Down
16 changes: 8 additions & 8 deletions src/lang/cs_CZ.json
Original file line number Diff line number Diff line change
Expand Up @@ -328,15 +328,15 @@
"{twitchFollowers:ninja} Followers"
]
},
"twitchViews": {
"name": "twitchViews:nickname",
"description": "Amount of views of a Twitch channel",
"detailedDescription": "Counts how many views has a Twitch channel, replace `nickname` with the desired channel name",
"twitchViewers": {
"name": "twitchViewers:nickname",
"description": "Amount of stream viewers",
"detailedDescription": "Counts how many viewers are there on an active stream, replace `nickname` with the desired channel name",
"usage": [
"{twitchViews:nickname}"
"{twitchViewers:nickname}"
],
"example": [
"{twitchViews:ninja} Views"
"{twitchViewers:ninja} Views"
]
},
"twitchChannelName": {
Expand Down Expand Up @@ -848,8 +848,8 @@
"statusCreated": "{CHECK_MARK} Follower counter created"
},
{
"name": "twitchViews",
"template": "{twitchViews:{RESOURCE}} sledujících",
"name": "twitchViewers",
"template": "Viewers {twitchViewers:{RESOURCE}}",
"statusCreating": "{LOADING} Creating views counter",
"statusCreated": "{CHECK_MARK} Views counter created"
}
Expand Down
16 changes: 8 additions & 8 deletions src/lang/de_DE.json
Original file line number Diff line number Diff line change
Expand Up @@ -328,15 +328,15 @@
"{twitchFollowers:ninja} Followers"
]
},
"twitchViews": {
"name": "twitchViews:nickname",
"description": "Amount of views of a Twitch channel",
"detailedDescription": "Counts how many views has a Twitch channel, replace `nickname` with the desired channel name",
"twitchViewers": {
"name": "twitchViewers:nickname",
"description": "Amount of stream viewers",
"detailedDescription": "Counts how many viewers are there on an active stream, replace `nickname` with the desired channel name",
"usage": [
"{twitchViews:nickname}"
"{twitchViewers:nickname}"
],
"example": [
"{twitchViews:ninja} Views"
"{twitchViewers:ninja} Views"
]
},
"twitchChannelName": {
Expand Down Expand Up @@ -848,8 +848,8 @@
"statusCreated": "{CHECK_MARK} Follower counter created"
},
{
"name": "twitchViews",
"template": "{twitchViews:{RESOURCE}} Views",
"name": "twitchViewers",
"template": "Viewers {twitchViewers:{RESOURCE}}",
"statusCreating": "{LOADING} Creating views counter",
"statusCreated": "{CHECK_MARK} Views counter created"
}
Expand Down
20 changes: 12 additions & 8 deletions src/lang/en_US.json
Original file line number Diff line number Diff line change
Expand Up @@ -247,12 +247,16 @@
"usage": ["{twitchFollowers:nickname}"],
"example": ["{twitchFollowers:ninja} Followers"]
},
"twitchViews": {
"name": "twitchViews:nickname",
"description": "Amount of views of a Twitch channel",
"detailedDescription": "Counts how many views has a Twitch channel, replace `nickname` with the desired channel name",
"usage": ["{twitchViews:nickname}"],
"example": ["{twitchViews:ninja} Views"]
"twitchViewers": {
"name": "twitchViewers:nickname",
"description": "Amount of stream viewers",
"detailedDescription": "Counts how many viewers are there on an active stream, replace `nickname` with the desired channel name",
"usage": [
"{twitchViewers:nickname}"
],
"example": [
"{twitchViewers:ninja} Views"
]
},
"twitchChannelName": {
"name": "twitchChannelName:nickname",
Expand Down Expand Up @@ -642,8 +646,8 @@
"statusCreated": "{CHECK_MARK} Follower counter created"
},
{
"name": "twitchViews",
"template": "{twitchViews:{RESOURCE}} Views",
"name": "twitchViewers",
"template": "Viewers {twitchViewers:{RESOURCE}}",
"statusCreating": "{LOADING} Creating views counter",
"statusCreated": "{CHECK_MARK} Views counter created"
}
Expand Down
20 changes: 10 additions & 10 deletions src/lang/es_ES.json
Original file line number Diff line number Diff line change
Expand Up @@ -328,15 +328,15 @@
"{twitchFollowers:ninja} Seguidores"
]
},
"twitchViews": {
"name": "twitchViews:nombre",
"description": "Cantidad de vistas de un canal de Twitch",
"detailedDescription": "Cuenta cuántas visualizaciones tiene un canal de Twitch, reemplaza `nombre` con el nombre del canal deseado",
"twitchViewers": {
"name": "twitchViewers:nickname",
"description": "Amount of stream viewers",
"detailedDescription": "Counts how many viewers are there on an active stream, replace `nickname` with the desired channel name",
"usage": [
"{twitchViews:nombre}"
"{twitchViewers:nickname}"
],
"example": [
"{twitchViews:ninja} Visualizaciones"
"{twitchViewers:ninja} Views"
]
},
"twitchChannelName": {
Expand Down Expand Up @@ -848,10 +848,10 @@
"statusCreated": "{CHECK_MARK} Contador de seguidores creado"
},
{
"name": "twitchViews",
"template": "{twitchViews:{RESOURCE}} Visitas",
"statusCreating": "{LOADING} Creando contador de visitas",
"statusCreated": "{CHECK_MARK} Contador de visitas creado"
"name": "twitchViewers",
"template": "Viewers {twitchViewers:{RESOURCE}}",
"statusCreating": "{LOADING} Creating views counter",
"statusCreated": "{CHECK_MARK} Views counter created"
}
]
},
Expand Down
20 changes: 10 additions & 10 deletions src/lang/fa_IR.json
Original file line number Diff line number Diff line change
Expand Up @@ -328,15 +328,15 @@
"{twitchFollowers:ninja} دنبال کننده ها"
]
},
"twitchViews": {
"name": "twitchViews:nickname",
"description": "تعداد بازدید های یک چنل توییچ",
"detailedDescription": "تعداد بازدید های یک چنل توییچ را می شمارد. قسمت `nickname` را با نام چنل توییچ دلخواه تغییر دهید",
"twitchViewers": {
"name": "twitchViewers:nickname",
"description": "Amount of stream viewers",
"detailedDescription": "Counts how many viewers are there on an active stream, replace `nickname` with the desired channel name",
"usage": [
"{twitchViews:nickname}"
"{twitchViewers:nickname}"
],
"example": [
"{twitchViews:ninja} بازدید ها"
"{twitchViewers:ninja} Views"
]
},
"twitchChannelName": {
Expand Down Expand Up @@ -848,10 +848,10 @@
"statusCreated": "{CHECK_MARK} شمارنده دنبال‌کننده ساخته شد"
},
{
"name": "twitchViews",
"template": "{twitchViews:{RESOURCE}} بازدید ها",
"statusCreating": "{LOADING} درحال ساخت شمارنده میزان بازدید ها",
"statusCreated": "{CHECK_MARK} شمارنده میزان بازدید ها ساخته شد"
"name": "twitchViewers",
"template": "Viewers {twitchViewers:{RESOURCE}}",
"statusCreating": "{LOADING} Creating views counter",
"statusCreated": "{CHECK_MARK} Views counter created"
}
]
},
Expand Down
16 changes: 8 additions & 8 deletions src/lang/fr_FR.json
Original file line number Diff line number Diff line change
Expand Up @@ -328,15 +328,15 @@
"{twitchFollowers:ninja} Followers"
]
},
"twitchViews": {
"name": "twitchViews:nickname",
"description": "Amount of views of a Twitch channel",
"detailedDescription": "Counts how many views has a Twitch channel, replace `nickname` with the desired channel name",
"twitchViewers": {
"name": "twitchViewers:nickname",
"description": "Amount of stream viewers",
"detailedDescription": "Counts how many viewers are there on an active stream, replace `nickname` with the desired channel name",
"usage": [
"{twitchViews:nickname}"
"{twitchViewers:nickname}"
],
"example": [
"{twitchViews:ninja} Views"
"{twitchViewers:ninja} Views"
]
},
"twitchChannelName": {
Expand Down Expand Up @@ -848,8 +848,8 @@
"statusCreated": "{CHECK_MARK} Follower counter created"
},
{
"name": "twitchViews",
"template": "{twitchViews:{RESOURCE}} Views",
"name": "twitchViewers",
"template": "Viewers {twitchViewers:{RESOURCE}}",
"statusCreating": "{LOADING} Creating views counter",
"statusCreated": "{CHECK_MARK} Views counter created"
}
Expand Down
16 changes: 8 additions & 8 deletions src/lang/he_IL.json
Original file line number Diff line number Diff line change
Expand Up @@ -328,15 +328,15 @@
"{twitchFollowers:ninja} Followers"
]
},
"twitchViews": {
"name": "twitchViews:nickname",
"description": "Amount of views of a Twitch channel",
"detailedDescription": "Counts how many views has a Twitch channel, replace `nickname` with the desired channel name",
"twitchViewers": {
"name": "twitchViewers:nickname",
"description": "Amount of stream viewers",
"detailedDescription": "Counts how many viewers are there on an active stream, replace `nickname` with the desired channel name",
"usage": [
"{twitchViews:nickname}"
"{twitchViewers:nickname}"
],
"example": [
"{twitchViews:ninja} Views"
"{twitchViewers:ninja} Views"
]
},
"twitchChannelName": {
Expand Down Expand Up @@ -848,8 +848,8 @@
"statusCreated": "{CHECK_MARK} Follower counter created"
},
{
"name": "twitchViews",
"template": "{twitchViews:{RESOURCE}} Views",
"name": "twitchViewers",
"template": "Viewers {twitchViewers:{RESOURCE}}",
"statusCreating": "{LOADING} Creating views counter",
"statusCreated": "{CHECK_MARK} Views counter created"
}
Expand Down
20 changes: 10 additions & 10 deletions src/lang/hi_IN.json
Original file line number Diff line number Diff line change
Expand Up @@ -328,15 +328,15 @@
"{twitchFollowers:ninja} Followers"
]
},
"twitchViews": {
"name": "twitchViews:nickname",
"description": "Amount of views of a Twitch channel",
"detailedDescription": "Counts how many views has a Twitch channel, replace `nickname` with the desired channel name",
"twitchViewers": {
"name": "twitchViewers:nickname",
"description": "Amount of stream viewers",
"detailedDescription": "Counts how many viewers are there on an active stream, replace `nickname` with the desired channel name",
"usage": [
"{twitchViews:nickname}"
"{twitchViewers:nickname}"
],
"example": [
"{twitchViews:ninja} Views"
"{twitchViewers:ninja} Views"
]
},
"twitchChannelName": {
Expand Down Expand Up @@ -848,10 +848,10 @@
"statusCreated": "{CHECK_MARK} अनुयायी काउंटर बनाई गई"
},
{
"name": "twitchViews",
"template": "{twitchFollowers:{RESOURCE}} ट्विच दर्शक",
"statusCreating": "{LOADING} व्यू काउंटर बनाई जा रही है",
"statusCreated": "{CHECK_MARK} व्यू काउंटर बनाया गया"
"name": "twitchViewers",
"template": "Viewers {twitchViewers:{RESOURCE}}",
"statusCreating": "{LOADING} Creating views counter",
"statusCreated": "{CHECK_MARK} Views counter created"
}
]
},
Expand Down
Loading

0 comments on commit 0cf2703

Please sign in to comment.