MCPcopy Create free account
hub / github.com/RTByte/rtbyte / run

Method run

src/events/rtbyteReady.js:13–48  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

11 }
12
13 async run() {
14 // Triggering initialization of the control guild if it hasn't been initialized
15 if (this.client.options.controlGuild && !this.client.settings.get('guilds.controlGuild')) await this.setControlGuild();
16
17 // Check to see that the bot is in at least one guild
18 if (!this.client.guilds.cache.size) {
19 await this.client.emit('error', 'Please add the bot to at least one guild.\nShutting down...');
20 await this.client.destroy();
21 }
22
23 // Check to see that there is a control guild specified
24 if (!this.client.settings.get('guilds.controlGuild')) {
25 await this.client.emit('error', 'Please specify the control guild in your client configs and ensure the bot has been added to it with Administrator permissions.\nShutting down...');
26 await this.client.destroy();
27 }
28
29 await this.client.emit('verbose', 'Verifying that all guilds are initialized...');
30
31 await this.client.guilds.cache.forEach(async (guild) => {
32 if (!guild.available) return;
33 if (this.client.settings.get('guildBlacklist').includes(guild.id)) {
34 guild.leave();
35 this.client.emit('warn', `Blacklisted guild detected: ${guild.name} (${guild.id})`);
36 } else {
37 // eslint-disable-next-line max-len
38 if ((!guild.settings.get('initialization.serverInitialized') || !guild.settings.get('channels.log')) && guild.id === this.client.settings.get('guilds.controlGuild')) await guild.rtbyteInit('control');
39 if ((!guild.settings.get('initialization.serverInitialized') || !guild.settings.get('channels.log')) && guild.id !== this.client.settings.get('guilds.controlGuild')) await guild.rtbyteInit();
40 await this.client.emit('verbose', `Verified initialization of guild: ${guild.name} (${guild.id})`);
41 }
42 });
43
44 await this.client.emit('verbose', 'All guilds verified!');
45 if (this.client.settings.get('logs.botReady')) await this.botReadyLog();
46
47 return;
48 }
49
50 async botReadyLog() {
51 const embed = new MessageEmbed()

Callers

nothing calls this directly

Calls 4

setControlGuildMethod · 0.80
leaveMethod · 0.80
rtbyteInitMethod · 0.80
botReadyLogMethod · 0.80

Tested by

no test coverage detected