Skip to content

Commit

Permalink
fixing types and files
Browse files Browse the repository at this point in the history
  • Loading branch information
trent-001 committed Jul 23, 2024
1 parent b914126 commit d72dda8
Show file tree
Hide file tree
Showing 6 changed files with 5 additions and 2,483 deletions.
5 changes: 0 additions & 5 deletions commands/remove.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,8 @@ import {
ChatInputCommandInteraction,
PermissionsBitField,
SlashCommandBuilder,
EmbedBuilder,
ChannelType,
ButtonBuilder,
ButtonStyle,
ActionRowBuilder,
} from "discord.js";
import { discord, AddButtonDataTwitch } from "..";
import { db } from "../db";
import * as schema from "../db/schema";
import { and, eq } from "drizzle-orm";
Expand Down
13 changes: 0 additions & 13 deletions db/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,3 @@ import postgres from "postgres";
// TypeScript type for the users table
const queryClient = postgres(process.env.POSTGRES_URL || "");
export const db = drizzle(queryClient, { schema });
// test();
async function test() {
await db.insert(schema.discordBotTwitch).values({
id: "8abb7df6-fd7d-4350-8f00-d2ca3eaf3ebe",
account_id: "123456789",
channel_id: "1262765510194364446",
server_id: "636803646536810496",
username: "troykomodo",
message_id: null,
social_links: false,
keep_vod: true,
});
}
36 changes: 1 addition & 35 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,12 @@ import {
GatewayIntentBits,
Partials,
Events,
PermissionsBitField,
ButtonBuilder,
ButtonStyle,
ActionRowBuilder,
REST,
Routes,
} from "discord.js";
import test from "./test";
import { readdirSync } from "fs";
import { join } from "path";
import { db } from "./db";
Expand Down Expand Up @@ -47,48 +45,19 @@ discord.login(process.env.DISCORD_TOKEN);
discord.on(Events.ClientReady, async () => {
console_log.colour(discord?.user?.username + " bot is ready", "green");
await registerSlashCommands();
// console.log("servers:", await getServers());
setInterval(timeCheck, 1000);
});
import "./events/interactionCreate";
function timeCheck() {
var now = new Date();
let minute = now.getMinutes();
let second = now.getSeconds();
if (minute % 5 === 0 && second === 0) {
if (minute % 10 === 0 && second === 0) {
TwitchEmbedLoop();
}
}
async function getServers() {
let servers = [];
for (const [index, server] of test.entries()) {
const discordServer = discord.guilds.cache.get(server.id);
if (!discordServer) continue;

const user = discordServer.members.cache.get("446931064506548224");
if (!user) continue;

if (!user.permissions) continue;

const perms = user.permissions.has(
PermissionsBitField.Flags.Administrator,
true
);
if (!perms) continue;

servers.push({
id: server.id,
name: server.name,
icon: discordServer.iconURL(),
member_count: discordServer.memberCount,
owner: discordServer.ownerId,
});
}
return servers;
}
const TwitchEmbedLoop = async () => {
const servers = await db.query.discordBotTwitch.findMany();
// console.log("🚀 ~ TwitchEmbedLoop ~ servers:", servers);
console_log.log(`Twitch Embeds Processing ${servers.length} Users`);
for (const [index, item] of servers.entries()) {
await twitchLiveEmbeds(item, index);
Expand Down Expand Up @@ -248,9 +217,6 @@ const twitchLiveEmbeds = async (item: ITwitch, index: number) => {
embeds: [embed],
components: [row],
})
.then(() => {
// console.log("Embed edited successfully.");
})
.catch(async (error) => {
const message = await channel.send({
content: mention,
Expand Down
5 changes: 1 addition & 4 deletions shard.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
import { ShardingManager } from "discord.js";
import { config } from "dotenv";

// Load environment variables from .env file (optional)
config();
import "dotenv/config";

const token = process.env.DISCORD_TOKEN || "your-token-goes-here";
const manager = new ShardingManager("./build/index.js", {
Expand Down
Loading

0 comments on commit d72dda8

Please sign in to comment.