Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

General Optimization #193

Merged
merged 5 commits into from
Oct 12, 2024
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
130 changes: 65 additions & 65 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions src/commands/discord/tbypass.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ export class TwitchChatRelay extends baseCommand {
const uniqueID = randomUUID();

const tUser = await this.client.prisma.twitch.findUnique({
select: {
verified: true,
username: true,
},
where: {
memberid: interaction.user.id
}
Expand Down
5 changes: 5 additions & 0 deletions src/commands/discord/tverify.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ export class TwitchVerify extends baseCommand {

// Check for the request and status
const userReq = await this.client.prisma.twitch.findUnique({
select: {
id: true,
username: true,
verified: true,
},
where: {
memberid: interaction.user.id,
username: twitchUsername,
Expand Down
3 changes: 3 additions & 0 deletions src/commands/twitch/link.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ export class LinkCommand extends baseTCommand {

// Check if user has already joined in the discord server
const dAccCount = await data.client.discord.prisma.members.findUnique({
select: {
rulesconfirmedon: true,
},
where: {
id: discordID,
}
Expand Down
41 changes: 23 additions & 18 deletions src/core/DiscordClient.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { ActivityType, Client, GatewayIntentBits, Partials, DefaultWebSocketManagerOptions } from "discord.js";
import config from '../config.json';
import { PrismaClient } from "@prisma/client";
import { suppressTracing } from "@sentry/core";
import Redis from "ioredis";
import { eventLogger } from "./helper/eventLogger";
import { DiscordEvents, RedisEvents } from "../events";
Expand Down Expand Up @@ -97,27 +98,31 @@ export class DiscordClient extends Client implements baseClient {
}

public async start(token: string) {
// Connect all services
await this.prisma.$connect();
if(this.redis.status === "close")
await this.redis.connect();
await this.login(token);

// Start all services
await new DiscordCommandHandler(this).commandRegister();
await this.loadServices();
this.updateStatus();

// Start helper clients
await this.twitch.start();
await this.youtube.start();
return await suppressTracing(async()=>{
// Connect all services
await this.prisma.$connect();
if(this.redis.status === "close")
await this.redis.connect();
await this.login(token);

// Start all services
await new DiscordCommandHandler(this).commandRegister();
await this.loadServices();
this.updateStatus();

// Start helper clients
await this.twitch.start();
await this.youtube.start();
});
}

public async dispose() {
// Close all connections
await this.prisma.$disconnect();
await this.redis.quit();
await this.destroy();
return await suppressTracing(async() => {
// Close all connections
await this.prisma.$disconnect();
await this.redis.quit();
await this.destroy();
});
}

public updateStatus() {
Expand Down
Loading