Skip to content

Commit 49c2c9c

Browse files
committed
Wait a moment for discord, if needed before launching factorio.
1 parent 7403476 commit 49c2c9c

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

constants/consts.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import "time"
44

55
const (
66
ProgName = "ChatWire"
7-
Version = "2651-1108.2024-0803"
7+
Version = "2652-11-11.2024-0408p"
88
CWEpoch = 1653239822390688174
99
SeenDivisor = 60
1010
SeenEpoch = 1546326000

main.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,7 @@ func BotReady(s *discordgo.Session, r *discordgo.Ready) {
197197

198198
//Reset attempt count, we are fully connected.
199199
DiscordConnectAttempts = 0
200+
support.BotIsReady = true
200201
}
201202

202203
func checkLockFile() {

support/factLauncher.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,18 @@ func injectSoftMod(fileName, folderName string) {
325325
}
326326
}
327327

328+
var BotIsReady bool
329+
330+
func waitForDiscord() {
331+
if BotIsReady {
332+
return
333+
}
334+
for x := 0; x < 5 && !BotIsReady; x++ {
335+
cwlog.DoLogCW("Waiting for Discord...")
336+
time.Sleep(time.Second)
337+
}
338+
}
339+
328340
/* Create config files, launch factorio */
329341
func launchFactorio() {
330342

@@ -338,6 +350,7 @@ func launchFactorio() {
338350

339351
fact.SetLastBan("")
340352

353+
waitForDiscord()
341354
glob.BootMessage = disc.SmartEditDiscordEmbed(cfg.Local.Channel.ChatChannel, glob.BootMessage, "Notice", "Launching Factorio...", glob.COLOR_GREEN)
342355

343356
/* Allow crash reports right away */

0 commit comments

Comments
 (0)