Fixing multiple reply bug
This commit is contained in:
parent
68b6312635
commit
53550fb12b
2 changed files with 28 additions and 14 deletions
4
.gitignore
vendored
4
.gitignore
vendored
|
@ -1,6 +1,8 @@
|
||||||
Geekbot.net/bin
|
Geekbot.net/bin
|
||||||
Geekbot.net/obj
|
Geekbot.net/obj
|
||||||
|
Tests/bin
|
||||||
|
Tests/obj
|
||||||
Backup/
|
Backup/
|
||||||
.vs/
|
.vs/
|
||||||
UpgradeLog.htm
|
UpgradeLog.htm
|
||||||
.idea
|
.idea
|
||||||
|
|
|
@ -70,7 +70,21 @@ namespace Geekbot.net
|
||||||
{
|
{
|
||||||
await client.LoginAsync(TokenType.Bot, token);
|
await client.LoginAsync(TokenType.Bot, token);
|
||||||
await client.StartAsync();
|
await client.StartAsync();
|
||||||
client.Connected += FinishStartup;
|
var isConneted = await isConnected();
|
||||||
|
if (isConneted)
|
||||||
|
{
|
||||||
|
await client.SetGameAsync("Ping Pong");
|
||||||
|
Console.WriteLine($"Now Connected to {client.Guilds.Count} Servers");
|
||||||
|
|
||||||
|
Console.WriteLine("Registering Stuff");
|
||||||
|
|
||||||
|
client.MessageReceived += HandleCommand;
|
||||||
|
client.MessageReceived += HandleMessageReceived;
|
||||||
|
client.UserJoined += HandleUserJoined;
|
||||||
|
await commands.AddModulesAsync(Assembly.GetEntryAssembly());
|
||||||
|
|
||||||
|
Console.WriteLine("Done and ready for use...\n");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (AggregateException)
|
catch (AggregateException)
|
||||||
{
|
{
|
||||||
|
@ -79,6 +93,15 @@ namespace Geekbot.net
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task<bool> isConnected()
|
||||||
|
{
|
||||||
|
while (!client.ConnectionState.Equals(ConnectionState.Connected))
|
||||||
|
{
|
||||||
|
await Task.Delay(25);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
public async Task Reconnect(Exception exception)
|
public async Task Reconnect(Exception exception)
|
||||||
{
|
{
|
||||||
Console.WriteLine("=========================================");
|
Console.WriteLine("=========================================");
|
||||||
|
@ -93,18 +116,7 @@ namespace Geekbot.net
|
||||||
|
|
||||||
public async Task FinishStartup()
|
public async Task FinishStartup()
|
||||||
{
|
{
|
||||||
await client.SetGameAsync("Ping Pong");
|
|
||||||
Console.WriteLine($"Now Connected to {client.Guilds.Count} Servers");
|
|
||||||
|
|
||||||
Console.WriteLine("Registering Stuff");
|
|
||||||
|
|
||||||
client.MessageReceived += HandleCommand;
|
|
||||||
client.MessageReceived += HandleMessageReceived;
|
|
||||||
client.UserJoined += HandleUserJoined;
|
|
||||||
// client.Disconnected += Reconnect;
|
|
||||||
await commands.AddModulesAsync(Assembly.GetEntryAssembly());
|
|
||||||
|
|
||||||
Console.WriteLine("Done and ready for use...\n");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task HandleCommand(SocketMessage messageParam)
|
public async Task HandleCommand(SocketMessage messageParam)
|
||||||
|
@ -130,7 +142,7 @@ namespace Geekbot.net
|
||||||
}
|
}
|
||||||
if (!(message.HasCharPrefix('!', ref argPos) || message.HasMentionPrefix(client.CurrentUser, ref argPos))) return;
|
if (!(message.HasCharPrefix('!', ref argPos) || message.HasMentionPrefix(client.CurrentUser, ref argPos))) return;
|
||||||
var context = new CommandContext(client, message);
|
var context = new CommandContext(client, message);
|
||||||
Task.Run(() => commands.ExecuteAsync(context, argPos, map));
|
Task.Run(async () => await commands.ExecuteAsync(context, argPos, map));
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task HandleMessageReceived(SocketMessage messsageParam)
|
public async Task HandleMessageReceived(SocketMessage messsageParam)
|
||||||
|
|
Loading…
Reference in a new issue