hopefully resist double-connecting
This commit is contained in:
parent
53c1d956b3
commit
5b3a645406
2
.vscode/launch.json
vendored
2
.vscode/launch.json
vendored
@ -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
|
||||
|
@ -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);
|
||||
|
Reference in New Issue
Block a user