private async Task HandleCommandAsync(SocketMessage arg) { var msg = arg as SocketUserMessage; if (msg == null) { return; } if (arg.Author.Id == 352216646267437059) { /// Get some informations about the bot for statistics purposes if (arg.Content == "<@&330483872544587776> Please send me your informations for comparison.") { List <ulong> users = new List <ulong>(); foreach (var g in client.Guilds) { foreach (var g2 in g.Users) { if (!users.Contains(g2.Id)) { users.Add(g2.Id); } } } int nbMsgs = 0; DateTime dt = DateTime.UtcNow; if (Directory.Exists("Saves/Stats/" + dt.Month.ToString())) { foreach (string s in Directory.GetFiles("Saves/Stats/" + dt.Month.ToString())) { nbMsgs += Convert.ToInt32(File.ReadAllText(s)); } } await(((ITextChannel)(arg.Channel))).SendMessageAsync($"<@{Sentences.idPikyu}> Here are the compare informations: " + client.Guilds.Count + "|" + users.Count + "|" + getLenghtFolder("Saves") + "o|Zirk|" + nbMsgs); } } /// When playing games else if (arg.Author.Id != Sentences.myId) { GameModule.Game game = games.Find(x => x.m_chan == arg.Channel); if (game != null) { game.CheckCorrect(arg.Content, arg.Author); } } int pos = 0; string prefix = prefixs[(arg.Channel as ITextChannel).GuildId]; if (msg.HasMentionPrefix(client.CurrentUser, ref pos) || (prefix != "" && msg.HasStringPrefix(prefix, ref pos))) { var context = new SocketCommandContext(client, msg); if (context.Guild == null) { await context.Channel.SendMessageAsync(Sentences.dontPm(446053427714326528)); // Workaround because can't get id of null guild return; } DateTime dt = DateTime.UtcNow; var result = await commands.ExecuteAsync(context, pos); // Count how many messages the bot receive if (result.IsSuccess && !context.User.IsBot) { commandReceived++; if (!Directory.Exists("Saves")) { Directory.CreateDirectory("Saves"); } if (!Directory.Exists("Saves/Stats")) { Directory.CreateDirectory("Saves/Stats"); } if (!Directory.Exists("Saves/Stats/" + dt.Month.ToString())) { Directory.CreateDirectory("Saves/Stats/" + dt.Month.ToString()); } if (File.Exists("Saves/Stats/" + dt.Month.ToString() + '/' + dt.Day.ToString() + ".dat")) { File.WriteAllText("Saves/Stats/" + dt.Month.ToString() + '/' + dt.Day.ToString() + ".dat", (Convert.ToInt32(File.ReadAllText("Saves/Stats/" + dt.Month.ToString() + '/' + dt.Day.ToString() + ".dat")) + 1).ToString()); } else { File.WriteAllText("Saves/Stats/" + dt.Month.ToString() + '/' + dt.Day.ToString() + ".dat", "1"); } File.WriteAllText("Saves/CommandReceived.dat", commandReceived + Environment.NewLine + lastHourSent); } } }