Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions .github/workflows/lockb.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ name: Update bun.lockb

on:
push:
branches:
- main
branches: [main, dev]

permissions:
contents: write
Expand Down Expand Up @@ -40,5 +39,5 @@ jobs:
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
git commit -m "Update bun.lockb (via GitHub Actions)"
git pull --rebase origin main
git push
git pull --rebase origin ${{ github.ref_name }}
git push origin ${{ github.ref_name }}
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Feedr strives for constant improvement, so here's what will be implemented
- YouTube Channel selector when using **/track**
- Make it easier to stop tracking channels by showing channels already in the guild when doing **/untrack**
- Other social media platforms
- Bluesky
- Bluesky
- Make it easier to switch discord channels for uploads so that **/untrack** then **/track** is not required
- **/tracked** command to show what channels are being tracked in the guild

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

# Changelog

## 1.4.0

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

## 1.3.0

- Moved database to SQLite
Expand Down
Binary file modified bun.lockb
Binary file not shown.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"type": "module",
"version": "1.3.0",
"devDependencies": {
"@types/bun": "1.1.10",
"@types/bun": "1.1.14",
"@typescript-eslint/eslint-plugin": "8.11.0",
"@typescript-eslint/parser": "8.11.0",
"eslint": "^8.57.0",
Expand Down
478 changes: 353 additions & 125 deletions src/commands.ts

Large diffs are not rendered by default.

21 changes: 12 additions & 9 deletions src/events/ready.ts
Original file line number Diff line number Diff line change
@@ -1,28 +1,31 @@
import { ActivityType, Events, PresenceUpdateStatus } from 'discord.js';
import client from '../index';
import fetchLatestUploads from '../utils/youtube/fetchLatestUploads';
import { config } from '../config';
import { checkIfStreamersAreLive } from '../utils/twitch/checkIfStreamerIsLive';
import { updateBotInfo } from '../utils/database';
import { ActivityType, Events, PresenceUpdateStatus } from "discord.js";

import client from "../index";
import fetchLatestUploads from "../utils/youtube/fetchLatestUploads";
import { config } from "../config";
import { checkIfStreamersAreLive } from "../utils/twitch/checkIfStreamerIsLive";
import { updateBotInfo } from "../utils/database";

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

const servers = client.guilds.cache.size;
const members = client.guilds.cache.reduce((acc, guild) => acc + guild.memberCount, 0)
const members = client.guilds.cache.reduce(
(acc, guild) => acc + guild.memberCount,
0,
);

await updateBotInfo(servers, members);
client.user.setPresence({
activities: [
{
name: `Notifying ${servers} servers [${members} members]`,
name: `Notifying ${servers.toLocaleString()} servers [${members.toLocaleString()} members]`,
type: ActivityType.Custom,
},
],
status: PresenceUpdateStatus.Online,
});

}

// Log into the bot
Expand Down
8 changes: 8 additions & 0 deletions src/types/database.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,11 @@ export interface dbTwitch {
twitch_channel_id: string;
is_live: boolean;
}

export type dbDiscordTable = {
guild_id: string;
guild_channel_id: string;
guild_platform: string;
platform_user_id: string;
guild_ping_role: null | string;
};
176 changes: 176 additions & 0 deletions src/types/innertube.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,176 @@
// NOTE: Experimental
// You think i was typing this all out manually? lol no :p

export type InnertubeSearchRequest = {
contents: {
twoColumnSearchResultsRenderer: {
primaryContents: {
sectionListRenderer: {
contents: Array<{
itemSectionRenderer?: {
contents: Array<{
didYouMeanRenderer?: {
didYouMean: {
runs: Array<{
text: string;
}>;
};
correctedQuery: {
runs: Array<{
text: string;
italics: boolean;
}>;
};
correctedQueryEndpoint: {
clickTrackingParams: string;
commandMetadata: {
webCommandMetadata: {
url: string;
webPageType: string;
rootVe: number;
};
};
searchEndpoint: {
query: string;
params: string;
};
};
trackingParams: string;
};
channelRenderer?: {
channelId: string;
title: {
simpleText: string;
};
navigationEndpoint: {
clickTrackingParams: string;
commandMetadata: {
webCommandMetadata: {
url: string;
webPageType: string;
rootVe: number;
apiUrl: string;
};
};
browseEndpoint: {
browseId: string;
canonicalBaseUrl: string;
};
};
thumbnail: {
thumbnails: Array<{
url: string;
width: number;
height: number;
}>;
};
descriptionSnippet?: {
runs: Array<{
text: string;
bold?: boolean;
}>;
};
shortBylineText: {
runs: Array<{
text: string;
navigationEndpoint: {
clickTrackingParams: string;
commandMetadata: {
webCommandMetadata: {
url: string;
webPageType: string;
rootVe: number;
apiUrl: string;
};
};
browseEndpoint: {
browseId: string;
canonicalBaseUrl: string;
};
};
}>;
};
videoCountText: {
accessibility: {
accessibilityData: {
label: string;
};
};
simpleText: string;
};
subscriptionButton: {
subscribed: boolean;
};
subscriberCountText: {
simpleText: string;
};
subscribeButton: {
buttonRenderer: {
style: string;
size: string;
isDisabled: boolean;
text: {
runs: Array<{
text: string;
}>;
};
navigationEndpoint: {
clickTrackingParams: string;
commandMetadata: {
webCommandMetadata: {
url: string;
webPageType: string;
rootVe: number;
};
};
signInEndpoint: {
nextEndpoint: {
clickTrackingParams: string;
commandMetadata: {
webCommandMetadata: {
url: string;
webPageType: string;
rootVe: number;
};
};
searchEndpoint: {
query: string;
params: string;
};
};
continueAction: string;
};
};
trackingParams: string;
};
};
trackingParams: string;
longBylineText: {
runs: Array<{
text: string;
navigationEndpoint: {
clickTrackingParams: string;
commandMetadata: {
webCommandMetadata: {
url: string;
webPageType: string;
rootVe: number;
apiUrl: string;
};
};
browseEndpoint: {
browseId: string;
canonicalBaseUrl: string;
};
};
}>;
};
};
}>;
};
}>;
};
};
};
};
};
21 changes: 20 additions & 1 deletion src/utils/database.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { dbYouTube } from "../types/database";
import type { dbDiscordTable, dbYouTube } from "../types/database";

import path from "path";

Expand Down Expand Up @@ -389,3 +389,22 @@ export async function updateBotInfo(
}
}
// #endregion

// #region i have no idea what im doing here

export async function getAllTrackedInGuild(
guild_id: string,
): Promise<dbDiscordTable[]> {
const query = `SELECT * FROM discord WHERE guild_id = ?`;

try {
const statement = db.prepare(query);
const results = statement.all(guild_id);

return results as dbDiscordTable[];
} catch (err) {
console.error("Error getting all tracked in guild:", err);
throw err;
}
}
// #endregion
32 changes: 32 additions & 0 deletions src/utils/youtube/search.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// NOTE: Experimental
import type { InnertubeSearchRequest } from "../../types/innertube";

export default async function (query: string) {
try {
const response = await fetch(
"https://www.youtube.com/youtubei/v1/search?prettyPrint=false",
{
headers: {
"X-Goog-Fieldmask":
"contents.twoColumnSearchResultsRenderer.primaryContents.sectionListRenderer.contents.itemSectionRenderer.contents",
},
body: JSON.stringify({
context: {
client: {
clientName: "WEB",
clientVersion: "2.20241212.08.00",
},
},
params: "EgIQAg%3D%3D",
query: query,
}),
method: "POST",
},
);
const data = (await response.json()) as Promise<InnertubeSearchRequest>;

console.dir(data, { depth: null });
} catch (err) {
console.error(err);
}
}
Loading