| 61 | } |
| 62 | |
| 63 | async setControlGuild() { |
| 64 | await this.client.emit('verbose', 'Setting control guild.'); |
| 65 | // Fail initialization if bot is not in the configured control guild |
| 66 | if (!this.client.guilds.cache.has(this.client.options.controlGuild)) return; |
| 67 | |
| 68 | // Making sure we have a fully resolved guild object |
| 69 | const controlGuild = await this.client.guilds.resolve(this.client.options.controlGuild); |
| 70 | |
| 71 | // Fail initialization if the control guild is not available for initialization |
| 72 | if (!controlGuild.available) return; |
| 73 | |
| 74 | // Fail initialization if bot doesn't have administrator permissions in the control guild |
| 75 | if (!controlGuild.me.permissions.has('ADMINISTRATOR')) return; |
| 76 | |
| 77 | // Registering control guild in clientStorage |
| 78 | await this.client.settings.update('guilds.controlGuild', controlGuild.id); |
| 79 | await this.client.settings.sync(true); |
| 80 | |
| 81 | return; |
| 82 | } |
| 83 | |
| 84 | }; |