Skip to content

Commit d76e655

Browse files
authored
Merge pull request #36 from GalvinPython/dev
2 parents 3c12cf8 + 9715bd3 commit d76e655

File tree

10 files changed

+613
-141
lines changed

10 files changed

+613
-141
lines changed

.github/workflows/lockb.yml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@ name: Update bun.lockb
22

33
on:
44
push:
5-
branches:
6-
- main
5+
branches: [main, dev]
76

87
permissions:
98
contents: write
@@ -40,5 +39,5 @@ jobs:
4039
git config --global user.name 'github-actions[bot]'
4140
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
4241
git commit -m "Update bun.lockb (via GitHub Actions)"
43-
git pull --rebase origin main
44-
git push
42+
git pull --rebase origin ${{ github.ref_name }}
43+
git push origin ${{ github.ref_name }}

README.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ Feedr strives for constant improvement, so here's what will be implemented
2525
- YouTube Channel selector when using **/track**
2626
- Make it easier to stop tracking channels by showing channels already in the guild when doing **/untrack**
2727
- Other social media platforms
28-
- Bluesky
28+
- Bluesky
2929
- Make it easier to switch discord channels for uploads so that **/untrack** then **/track** is not required
3030
- **/tracked** command to show what channels are being tracked in the guild
3131

@@ -48,6 +48,13 @@ Feedr requires Bun in order to work
4848

4949
# Changelog
5050

51+
## 1.4.0
52+
53+
- Added a new command! `/tracked` ([#50](https://github.com/GalvinPython/feedr/issues/50))
54+
- See all the tracked channels in your server
55+
- The channel you ran the command in will appear first as there is no option to only see the current channel for now
56+
- Locale improvments ([#43](https://github.com/GalvinPython/feedr/issues/43))
57+
5158
## 1.3.0
5259

5360
- Moved database to SQLite

bun.lockb

0 Bytes
Binary file not shown.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"type": "module",
55
"version": "1.3.0",
66
"devDependencies": {
7-
"@types/bun": "1.1.10",
7+
"@types/bun": "1.1.14",
88
"@typescript-eslint/eslint-plugin": "8.11.0",
99
"@typescript-eslint/parser": "8.11.0",
1010
"eslint": "^8.57.0",

src/commands.ts

Lines changed: 353 additions & 125 deletions
Large diffs are not rendered by default.

src/events/ready.ts

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,31 @@
1-
import { ActivityType, Events, PresenceUpdateStatus } from 'discord.js';
2-
import client from '../index';
3-
import fetchLatestUploads from '../utils/youtube/fetchLatestUploads';
4-
import { config } from '../config';
5-
import { checkIfStreamersAreLive } from '../utils/twitch/checkIfStreamerIsLive';
6-
import { updateBotInfo } from '../utils/database';
1+
import { ActivityType, Events, PresenceUpdateStatus } from "discord.js";
2+
3+
import client from "../index";
4+
import fetchLatestUploads from "../utils/youtube/fetchLatestUploads";
5+
import { config } from "../config";
6+
import { checkIfStreamersAreLive } from "../utils/twitch/checkIfStreamerIsLive";
7+
import { updateBotInfo } from "../utils/database";
78

89
// update the bot's presence
910
async function updatePresence() {
1011
if (!client?.user) return;
1112

1213
const servers = client.guilds.cache.size;
13-
const members = client.guilds.cache.reduce((acc, guild) => acc + guild.memberCount, 0)
14+
const members = client.guilds.cache.reduce(
15+
(acc, guild) => acc + guild.memberCount,
16+
0,
17+
);
1418

1519
await updateBotInfo(servers, members);
1620
client.user.setPresence({
1721
activities: [
1822
{
19-
name: `Notifying ${servers} servers [${members} members]`,
23+
name: `Notifying ${servers.toLocaleString()} servers [${members.toLocaleString()} members]`,
2024
type: ActivityType.Custom,
2125
},
2226
],
2327
status: PresenceUpdateStatus.Online,
2428
});
25-
2629
}
2730

2831
// Log into the bot

src/types/database.d.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,11 @@ export interface dbTwitch {
77
twitch_channel_id: string;
88
is_live: boolean;
99
}
10+
11+
export type dbDiscordTable = {
12+
guild_id: string;
13+
guild_channel_id: string;
14+
guild_platform: string;
15+
platform_user_id: string;
16+
guild_ping_role: null | string;
17+
};

src/types/innertube.d.ts

Lines changed: 176 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,176 @@
1+
// NOTE: Experimental
2+
// You think i was typing this all out manually? lol no :p
3+
4+
export type InnertubeSearchRequest = {
5+
contents: {
6+
twoColumnSearchResultsRenderer: {
7+
primaryContents: {
8+
sectionListRenderer: {
9+
contents: Array<{
10+
itemSectionRenderer?: {
11+
contents: Array<{
12+
didYouMeanRenderer?: {
13+
didYouMean: {
14+
runs: Array<{
15+
text: string;
16+
}>;
17+
};
18+
correctedQuery: {
19+
runs: Array<{
20+
text: string;
21+
italics: boolean;
22+
}>;
23+
};
24+
correctedQueryEndpoint: {
25+
clickTrackingParams: string;
26+
commandMetadata: {
27+
webCommandMetadata: {
28+
url: string;
29+
webPageType: string;
30+
rootVe: number;
31+
};
32+
};
33+
searchEndpoint: {
34+
query: string;
35+
params: string;
36+
};
37+
};
38+
trackingParams: string;
39+
};
40+
channelRenderer?: {
41+
channelId: string;
42+
title: {
43+
simpleText: string;
44+
};
45+
navigationEndpoint: {
46+
clickTrackingParams: string;
47+
commandMetadata: {
48+
webCommandMetadata: {
49+
url: string;
50+
webPageType: string;
51+
rootVe: number;
52+
apiUrl: string;
53+
};
54+
};
55+
browseEndpoint: {
56+
browseId: string;
57+
canonicalBaseUrl: string;
58+
};
59+
};
60+
thumbnail: {
61+
thumbnails: Array<{
62+
url: string;
63+
width: number;
64+
height: number;
65+
}>;
66+
};
67+
descriptionSnippet?: {
68+
runs: Array<{
69+
text: string;
70+
bold?: boolean;
71+
}>;
72+
};
73+
shortBylineText: {
74+
runs: Array<{
75+
text: string;
76+
navigationEndpoint: {
77+
clickTrackingParams: string;
78+
commandMetadata: {
79+
webCommandMetadata: {
80+
url: string;
81+
webPageType: string;
82+
rootVe: number;
83+
apiUrl: string;
84+
};
85+
};
86+
browseEndpoint: {
87+
browseId: string;
88+
canonicalBaseUrl: string;
89+
};
90+
};
91+
}>;
92+
};
93+
videoCountText: {
94+
accessibility: {
95+
accessibilityData: {
96+
label: string;
97+
};
98+
};
99+
simpleText: string;
100+
};
101+
subscriptionButton: {
102+
subscribed: boolean;
103+
};
104+
subscriberCountText: {
105+
simpleText: string;
106+
};
107+
subscribeButton: {
108+
buttonRenderer: {
109+
style: string;
110+
size: string;
111+
isDisabled: boolean;
112+
text: {
113+
runs: Array<{
114+
text: string;
115+
}>;
116+
};
117+
navigationEndpoint: {
118+
clickTrackingParams: string;
119+
commandMetadata: {
120+
webCommandMetadata: {
121+
url: string;
122+
webPageType: string;
123+
rootVe: number;
124+
};
125+
};
126+
signInEndpoint: {
127+
nextEndpoint: {
128+
clickTrackingParams: string;
129+
commandMetadata: {
130+
webCommandMetadata: {
131+
url: string;
132+
webPageType: string;
133+
rootVe: number;
134+
};
135+
};
136+
searchEndpoint: {
137+
query: string;
138+
params: string;
139+
};
140+
};
141+
continueAction: string;
142+
};
143+
};
144+
trackingParams: string;
145+
};
146+
};
147+
trackingParams: string;
148+
longBylineText: {
149+
runs: Array<{
150+
text: string;
151+
navigationEndpoint: {
152+
clickTrackingParams: string;
153+
commandMetadata: {
154+
webCommandMetadata: {
155+
url: string;
156+
webPageType: string;
157+
rootVe: number;
158+
apiUrl: string;
159+
};
160+
};
161+
browseEndpoint: {
162+
browseId: string;
163+
canonicalBaseUrl: string;
164+
};
165+
};
166+
}>;
167+
};
168+
};
169+
}>;
170+
};
171+
}>;
172+
};
173+
};
174+
};
175+
};
176+
};

src/utils/database.ts

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { dbYouTube } from "../types/database";
1+
import type { dbDiscordTable, dbYouTube } from "../types/database";
22

33
import path from "path";
44

@@ -389,3 +389,22 @@ export async function updateBotInfo(
389389
}
390390
}
391391
// #endregion
392+
393+
// #region i have no idea what im doing here
394+
395+
export async function getAllTrackedInGuild(
396+
guild_id: string,
397+
): Promise<dbDiscordTable[]> {
398+
const query = `SELECT * FROM discord WHERE guild_id = ?`;
399+
400+
try {
401+
const statement = db.prepare(query);
402+
const results = statement.all(guild_id);
403+
404+
return results as dbDiscordTable[];
405+
} catch (err) {
406+
console.error("Error getting all tracked in guild:", err);
407+
throw err;
408+
}
409+
}
410+
// #endregion

src/utils/youtube/search.ts

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// NOTE: Experimental
2+
import type { InnertubeSearchRequest } from "../../types/innertube";
3+
4+
export default async function (query: string) {
5+
try {
6+
const response = await fetch(
7+
"https://www.youtube.com/youtubei/v1/search?prettyPrint=false",
8+
{
9+
headers: {
10+
"X-Goog-Fieldmask":
11+
"contents.twoColumnSearchResultsRenderer.primaryContents.sectionListRenderer.contents.itemSectionRenderer.contents",
12+
},
13+
body: JSON.stringify({
14+
context: {
15+
client: {
16+
clientName: "WEB",
17+
clientVersion: "2.20241212.08.00",
18+
},
19+
},
20+
params: "EgIQAg%3D%3D",
21+
query: query,
22+
}),
23+
method: "POST",
24+
},
25+
);
26+
const data = (await response.json()) as Promise<InnertubeSearchRequest>;
27+
28+
console.dir(data, { depth: null });
29+
} catch (err) {
30+
console.error(err);
31+
}
32+
}

0 commit comments

Comments
 (0)