Skip to content

Commit 56f672b

Browse files
committed
refactor(core/client): Move sync/hubServer setup to single ready event
1 parent 6a2a1b6 commit 56f672b

File tree

3 files changed

+13
-11
lines changed

3 files changed

+13
-11
lines changed

core/client.js

+2-11
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
11
const path = require('path')
22
const { AkairoClient, CommandHandler, ListenerHandler } = require('discord-akairo')
3-
const Sync = require('./sync.js')
4-
const HubServer = require('./hubServer.js')
53
const database = require('../database/index.js')
64
const { ownerID, prefix } = require('../config.js')
7-
const EmojiVotingPoll = require('./poll/EmojiVotingPoll.js')
8-
const RenameVotingPoll = require('./poll/RenameVotingPoll.js')
95

106
module.exports = class RinonClient extends AkairoClient {
117
constructor() {
@@ -45,13 +41,8 @@ module.exports = class RinonClient extends AkairoClient {
4541
this.commandHandler.useListenerHandler(this.listenerHandler)
4642
this.listenerHandler.loadAll()
4743

48-
this.once('ready', () => {
49-
this.sync = new Sync(this)
50-
this.hubServer = new HubServer(this)
51-
// NOTE: This stays here because the 2 classes depend on the `hubServer[votingChannel]` props
52-
this.hubServer.polls = { emoji: new EmojiVotingPoll(this), rename: new RenameVotingPoll(this) }
53-
this.sync.status()
54-
})
44+
this.sync = null
45+
this.hubServer = null
5546
}
5647

5748
async login(token) {

core/hubServer.js

+6
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,16 @@
11
const { hubServerID } = require('../config.js')
22
const regexes = require('../util/regexes.js')
3+
const EmojiVotingPoll = require('./poll/EmojiVotingPoll.js')
4+
const RenameVotingPoll = require('./poll/RenameVotingPoll.js')
35

46
module.exports = class HubServer {
57
constructor(client) {
68
this.client = client
79
this.guild = client.guilds.cache.get(hubServerID)
10+
this.polls = {
11+
emoji: new EmojiVotingPoll(client),
12+
rename: new RenameVotingPoll(client),
13+
}
814
}
915

1016
_getChannel(name) {

listeners/ready.js

+5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
const { Listener } = require('discord-akairo')
2+
const Sync = require('../core/sync.js')
3+
const HubServer = require('../core/hubServer.js')
24

35
module.exports = class ReadyListener extends Listener {
46
constructor() {
@@ -10,6 +12,9 @@ module.exports = class ReadyListener extends Listener {
1012
}
1113

1214
exec() {
15+
this.client.sync = new Sync(this.client)
16+
this.client.hubServer = new HubServer(this.client)
17+
this.client.sync.status()
1318
console.log(`${this.client.user.tag} ready!`)
1419
}
1520
}

0 commit comments

Comments
 (0)