public void Can_Log_Message() { File.Delete(Constants.MessageCountPath); bool success = MessageCountController.MessageRecord(1); Assert.That(success, Is.EqualTo(true)); File.Delete(Constants.MessageCountPath); }
public void Can_Get_MessageCount_Check() { File.Delete(Constants.MessageCountPath); MessageCountController.MessageRecord(1); string count = MessageCountController.GetMessages(1); Assert.AreEqual($"<@!1> has posted 1 messages", count); File.Delete(Constants.MessageCountPath); }
/// <summary> /// Tells disbott what to do with incoming commands /// </summary> /// <param name="messageParam"></param> /// <returns></returns> public async Task HandleCommand(SocketMessage messageParam) { // Don't process the command if it was a System Message var message = messageParam as SocketUserMessage; if (message == null) { return; } // Create a number to track where the prefix ends and the command begins int argPos = 0; // Determine if the message is a command, based on if it starts with '!' or a mention prefix if (message.HasMentionPrefix(_client.CurrentUser, ref argPos)) { // Create a Command Context var context = new CommandContext(_client, message); // Execute the command. (result does not indicate a return value, // rather an object stating if the command executed succesfully) var result = await _commands.ExecuteAsync(context, argPos); if (!result.IsSuccess) { await message.Channel.SendMessageAsync(result.ErrorReason); } if (Constants.DANKMODEACTIVATED == true) { var value = await GiphyController.GetRandomGif("Dank"); await message.Channel.SendMessageAsync(value); } } if (message.Author.Id != _client.CurrentUser.Id) { // MessageCount Record MessageCountController.MessageRecord(message.Author.Id); } }