Skip to content

Commit b827cd0

Browse files
committed
Startup: add early exit if the home guild doesn't exist
1 parent ddba7e6 commit b827cd0

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

Events/ReadyEvent.cs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@ public class ReadyEvent
66
{
77
public static async Task OnReady(DiscordClient client, SessionCreatedEventArgs _)
88
{
9-
10-
homeGuild = await discord.GetGuildAsync(cfgjson.ServerID);
11-
129
try
1310
{
1411
if (!LogChannelHelper.ready)
@@ -47,6 +44,17 @@ public static async Task OnReady(DiscordClient client, SessionCreatedEventArgs _
4744

4845
public static async Task OnStartup(DiscordClient client)
4946
{
47+
try
48+
{
49+
homeGuild = await discord.GetGuildAsync(cfgjson.ServerID);
50+
}
51+
catch
52+
{
53+
discord.Logger.LogCritical("Error retrieving the home guild using the configured serverID! " +
54+
"Please check that the bot is in the server and that the configuration is correct.");
55+
Environment.Exit(1);
56+
}
57+
5058
// wait until the log helper is ready
5159
while (true)
5260
{

0 commit comments

Comments
 (0)