hopefully resist double-connecting

This commit is contained in:
Adam R Grey 2022-01-31 13:59:41 -05:00
parent 53c1d956b3
commit 5b3a645406
2 changed files with 14 additions and 6 deletions

2
.vscode/launch.json vendored
View File

@ -10,7 +10,7 @@
"request": "launch",
"preLaunchTask": "build",
// If you have changed target frameworks, make sure to update the program path.
"program": "${workspaceFolder}/bin/Debug/net5.0/silverworker-discord.dll",
"program": "${workspaceFolder}/bin/Debug/net6.0/silverworker-discord.dll",
"args": [],
"cwd": "${workspaceFolder}",
// For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console

View File

@ -18,6 +18,7 @@ namespace silverworker_discord
class Program
{
private DiscordSocketClient _client;
private bool eventsSignedUp = false;
private Random r = new Random();
IConfigurationRoot config = new ConfigurationBuilder()
@ -53,11 +54,18 @@ namespace silverworker_discord
await _client.StartAsync();
_client.Ready += () => Task.Run(() =>
{
if (!eventsSignedUp)
{
Console.WriteLine("Bot is connected! going to sign up for message received and user joined in client ready");
_client.MessageReceived += MessageReceived;
_client.UserJoined += UserJoined;
}
else
{
Console.WriteLine("bot appears to be RE connected, so I'm not going to sign up twice");
}
});
// Block this task until the program is closed.
await Task.Delay(-1);