-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add
GatewayEvent
decorator for marking methods as event liste…
…ners
- Loading branch information
Showing
27 changed files
with
1,565 additions
and
1,565 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"editor.codeActionsOnSave": { | ||
"source.fixAll.eslint": "explicit" | ||
}, | ||
|
||
"eslint.validate": [ | ||
"javascript", | ||
"typescript" | ||
], | ||
} |
Submodule locales
updated
29 files
+1 −1 | src/locales/bg.yml | |
+1 −1 | src/locales/cs.yml | |
+1 −1 | src/locales/da.yml | |
+1 −1 | src/locales/de.yml | |
+1 −1 | src/locales/el.yml | |
+1 −1 | src/locales/en.yml | |
+1 −1 | src/locales/es.yml | |
+1 −1 | src/locales/fi.yml | |
+1 −1 | src/locales/fr.yml | |
+1 −1 | src/locales/hi.yml | |
+1 −1 | src/locales/hr.yml | |
+1 −1 | src/locales/hu.yml | |
+1 −1 | src/locales/id.yml | |
+1 −1 | src/locales/it.yml | |
+1 −1 | src/locales/ja.yml | |
+1 −1 | src/locales/ko.yml | |
+1 −1 | src/locales/lt.yml | |
+1 −1 | src/locales/nl.yml | |
+1 −1 | src/locales/no.yml | |
+1 −1 | src/locales/pl.yml | |
+1 −1 | src/locales/pt.yml | |
+1 −1 | src/locales/ro.yml | |
+1 −1 | src/locales/ru.yml | |
+1 −1 | src/locales/sv.yml | |
+1 −1 | src/locales/th.yml | |
+1 −1 | src/locales/tr.yml | |
+1 −1 | src/locales/uk.yml | |
+1 −1 | src/locales/vi.yml | |
+1 −1 | src/locales/zh.yml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import db from './utils/Db.js'; | ||
import Scheduler from './services/SchedulerService.js'; | ||
import { startApi } from './api/index.js'; | ||
import { isDevBuild } from './utils/Constants.js'; | ||
import { VoteManager } from './managers/VoteManager.js'; | ||
import { ClusterManager } from 'discord-hybrid-sharding'; | ||
import syncBotlistStats from './scripts/tasks/syncBotlistStats.js'; | ||
import deleteExpiredInvites from './scripts/tasks/deleteExpiredInvites.js'; | ||
import updateBlacklists from './scripts/tasks/updateBlacklists.js'; | ||
import deleteOldMessages from './scripts/tasks/deleteOldMessages.js'; | ||
import 'dotenv/config'; | ||
import { getUsername, wait } from './utils/Utils.js'; | ||
import Logger from './utils/Logger.js'; | ||
|
||
const clusterManager = new ClusterManager('build/index.js', { | ||
token: process.env.TOKEN, | ||
shardsPerClusters: 2, | ||
}); | ||
|
||
clusterManager.on('clusterCreate', async (cluster) => { | ||
// if it is the last cluster | ||
if (cluster.id === clusterManager.totalClusters - 1) { | ||
const scheduler = new Scheduler(); | ||
// remove expired blacklists or set new timers for them | ||
const serverQuery = { where: { hubs: { some: { expires: { isSet: true } } } } }; | ||
const userQuery = { where: { blacklistedFrom: { some: { expires: { isSet: true } } } } }; | ||
updateBlacklists(await db.blacklistedServers.findMany(serverQuery), scheduler) | ||
.catch(Logger.error); | ||
|
||
updateBlacklists(await db.userData.findMany(userQuery), scheduler) | ||
.catch(Logger.error); | ||
|
||
// code must be in production to run these tasks | ||
if (isDevBuild) return; | ||
// give time for shards to connect for these tasks | ||
await wait(10_000); | ||
|
||
// perform start up tasks | ||
syncBotlistStats(clusterManager).catch(Logger.error); | ||
deleteOldMessages().catch(Logger.error); | ||
deleteExpiredInvites().catch(Logger.error); | ||
|
||
scheduler.addRecurringTask('deleteExpiredInvites', 60 * 60 * 1_000, deleteExpiredInvites); | ||
scheduler.addRecurringTask('deleteOldMessages', 60 * 60 * 12_000, deleteOldMessages); | ||
scheduler.addRecurringTask('syncBotlistStats', 60 * 10_000, () => | ||
syncBotlistStats(clusterManager), | ||
); | ||
} | ||
}); | ||
|
||
const voteManager = new VoteManager(clusterManager); | ||
voteManager.on('vote', async (vote) => { | ||
const username = (await getUsername(clusterManager, vote.user)) ?? undefined; | ||
await voteManager.incrementUserVote(vote.user, username); | ||
await voteManager.addVoterRole(vote.user); | ||
await voteManager.announceVote(vote); | ||
}); | ||
|
||
// spawn clusters and start the api that handles nsfw filter and votes | ||
clusterManager.spawn({ timeout: -1 }) | ||
.then(() => startApi({ voteManager })) | ||
.catch(Logger.error); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.