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 improvement #113

Merged
merged 6 commits into from
May 23, 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
7 changes: 7 additions & 0 deletions src/commands/discord/leaderboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,13 @@ export class leaderboardCommand extends baseCommand {
username: true,
points: true
},
where: {
username: {
not: {
contains: "Deleted Account"
}
}
},
orderBy: {
points: 'desc'
},
Expand Down
13 changes: 7 additions & 6 deletions src/core/DiscordClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export class DiscordClient extends Client implements baseClient {
events;
twitch: TwitchClient;
youtube: YoutubeClient;
trimCommitHash: string;

constructor() {
super({
Expand All @@ -55,6 +56,11 @@ export class DiscordClient extends Client implements baseClient {
]
});

// Initalize fields
this.trimCommitHash = process.env['COMMITHASH'] ?? "???";
if(this.trimCommitHash && this.trimCommitHash.length > 7)
this.trimCommitHash = this.trimCommitHash.substring(0, 7);

// Initalize components
this.logger = new eventLogger(this);
this.redis = new Redis((process.env["ISDOCKER"] && !process.env["REDIS_CONN"]) ?
Expand Down Expand Up @@ -130,15 +136,10 @@ export class DiscordClient extends Client implements baseClient {
}

public updateStatus() {
// Get and trim the commit hash
let commitHash = process.env['COMMITHASH'];
if(commitHash && commitHash.length > 7)
commitHash = commitHash.substring(0, 7);

this.user?.setPresence({
status: "online",
activities: [{
name: `${this.guilds.cache.find(g=>g.id===this.config.guildID)?.memberCount} cuties :Þ | ver ${commitHash ?? "???"}`,
name: `${this.guilds.cache.find(g=>g.id===this.config.guildID)?.memberCount} cuties :Þ | ver ${this.trimCommitHash}`,
type: ActivityType.Watching,
}],
});
Expand Down
2 changes: 1 addition & 1 deletion src/core/helper/eventLogger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export class eventLogger {
.setDescription(log.message)
.setColor(this.EmbedColor(log.type))
.setTimestamp()
.setFooter({text: "Internal Report System"});
.setFooter({text: `Internal Report System | ver ${this.client.trimCommitHash}`});

// Add the metadata if it exists
if(log.metadata)
Expand Down
11 changes: 11 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,21 @@ CoreClient
* Handle cleanups
*/
async function quitSignalHandler() {
// Log initial shutdown message
await CoreClient.logger.sendLog({
type: "Info",
message: "Shutdown Initiated... View logs for shutdown completion."
});
console.log("Shutdown Initiated...");

// Perform cleanup
await CoreClient.dispose();
await CoreClient.twitch.dispose();
await CoreClient.youtube.dispose();
await flush(15000);

// Complete the shutdown
console.log("Shutdown Complete!");
process.exit(0);
}

Expand Down